Page 4 of 6

Re: Switchking on Raspberry Pi

Posted: Tue 04 Feb 2014, 21:30
by erlendfalch
Hi again,

Switch King is working, and I hope my comments to your (almost;-) ) flawless instructions may help.

One thing remaining is to get switckingd to start at boot. Seems like there is something wrong with the service as is. Works on manual start of service.

But thanks a lot! :clap:

Re: Switchking on Raspberry Pi

Posted: Wed 05 Feb 2014, 09:48
by gorhak
To make it start on boot try this (you made this with telldusd I suppose)
sudo update-rc.d switchkingd defaults

If you want to monitor that switchking service is running, and restart it automatically if not, yuo can do like this
## Create a new directory
sudo mkdir /home/pi/bin
## Create a new file
sudo nano /home/pi/bin/switchking.sh
## Copy these into the file:

#!/bin/bash
# Start SwitchKing service
status=`nice -n19 sudo service switchkingd status`
if [[ $status != "switchkingd is running." ]]
then
date >>/home/pi/bin/switchking_restart_logg.txt
echo "SwitchKing is Not Running! Restarts Now" >>/home/pi/bin/switchking_restart_logg.txt
sudo chmod 666 /home/pi/bin/switchking_restart_logg.txt
sudo service switchkingd start
# else
# date >>/home/pi/bin/switchking_restart_logg.txt
# echo "SwitchKing is Running" >>/home/pi/bin/switchking_restart_logg.txt
fi
exit 0

## Make the file executable
sudo chmod +x /home/pi/bin/switchking.sh

## Add a crontab-job that runs this script regularly, run
crontab -e
## this opens the crontab file in nano.
## Add these two lines at the end of the file and save:

#min hour day month weekday command
*/1 * * * * nice -n19 /home/pi/bin/switchking.sh

## Now is switchkingd service checked every minute (*/1). Try stop the service manually
sudo service switchkingd stop

## Whithin a minute the service should be restarted and a loggfile will be created /home/pi/bin/switchking_restart_logg.txt
/Göran

Re: Switchking on Raspberry Pi

Posted: Wed 05 Feb 2014, 12:53
by erlendfalch
Yeah, I did try sudo update-rc.d switchkingd defaults, but it printed out what seemed like warnings to me (not errors).

Anyway, if I implement your excellent cron job, I guess I am not required to get the service running at boot anyway. Thanks a lot for that, cause it has crashed on me once :-)

Re: Switchking on Raspberry Pi

Posted: Wed 19 Feb 2014, 22:44
by poddare
Har fått allt att funka till slut, har följt alla instruktioner och listat ut en del själv, är nybörjare med Linux men det blir lättare med tiden :) Har ikväll fått allt att snurra, Switchking som en service som startar om av sig själv, hade problem att få igång det som en service men det berodde på sökvägarna i /etc/init.d/switckingd. Kan inte säga om det var jag eller guiden som var "boven". Vad som är viktigt är att läsa igenom allt innan, hade själv lite bråttom i början men tar man sig tid så funkar allt.
Har inte testat över så lång tid men än sålänge snurrar allt alldeles utmärkt, prestandan i Iphone-appen samt klienten är fullt acceptabel, det gick snabbare på en bärbar, men det funkar riktigt bra med den lilla raspberryn.
Vore snyggt om man kunde göra en färdig image av hela operativet med Switcking installerat så det bara är att kopiera in sin egen databas...

Re: Switchking on Raspberry Pi

Posted: Thu 20 Feb 2014, 11:15
by RealElwood
Kan man inte göra en image på ditt SD kort bara, och byta ut databasen mot en tom fil?

Re: Switchking on Raspberry Pi

Posted: Tue 25 Feb 2014, 13:48
by erlendfalch
My experience with the Raspberry so far:

Setup:
Four temperature zones, which each has it's data source and switches to the electric oven.
- Different schedules to enable home and away mode, as well as night and day temperature
10 or so switches or dimmers
- One using schedule to turn on light early in the morning.

The server seems to crash rather frequently, especially if I use a remote control multiple times.
The server is quite good at recovering from crash, but if lights has been changed "manually" (remote switches), Switch King wants to override this by setting everything according to its status.
Performance on the server is starting to be really low (many devices). I have reduced the log history on data sources, but not tried any other tuning yet.

I guess I need to put some effort into tuning, but if anyone else have done some successful changes, feel free to share :-)

Btw: I am Norwegian, so I am perfectly capable of reading Swedish if you prefer posting in native language. I just use English to match a larger audience :)

Re: Switchking on Raspberry Pi

Posted: Mon 03 Mar 2014, 20:45
by Ola
gorhak wrote:Hello, I must correct myself. This is how i did it.

I bought a fast SDHC card 8GB Transcend TS8GSDHC10U1 (Netonnet 169kr)
and Im running at 950MHz overclocking.

I used image: 2014-01-07-wheezy-raspbian.img from raspberrypi.org/downloads homepage

Run frittefrax superb description but with some small corrections and testpoints
Start with no 1 ,2 and 4
sudo chmod 666 /etc/tellstick.conf

## edit tellstick.conf
sudo nano /etc/tellstick.conf
*change to true on line 4: to make Duo work
ignoreControllerConfirmation = "true"

edit the Example device to some device you already have, in my case: selflearning-switch:nexa code--111:1

#device {
# id = 1
# name = "Example device"
# protocol = "arctech"
# model = "codeswitch"
# parameters {
# house = "A"
# unit = "1"
# }
#}
device {
id = 1
name = "Example device"
controller = 0
protocol = "arctech"
model = "selflearning-switch:nexa"
parameters {
# devices = ""
house = "111"
unit = "1"
# code = ""
# system = ""
# units = ""
# fade = ""
}
}

## Restart telldus
sudo service telldusd restart

## Run tdtool, should be able to swich yuor device
tdtool --list
tdtool -n 1

## Install monodevelop, this give an complete mono installation with directory 2.0
sudo apt-get install monodevelop

## Install SwitchKing, no service scripts yet
Do nr (5) and 6.

## Run SwitchKing from prompt (running on softfloat)
mono /bin/SwitchKing/Bin/SwitchKing.exe terminal 8080 8800
Hi Guys,

Are there any kind experts out there who can give me a clue? I have proceeded all steps as per your excellent guides, but starting SwitchKing will give me 20 lines of error messeges, starting with:

Mono.Data.Sqlite.SqliteException: Unable to open the database file

I have extracted the database file and given it read/write permissions.

Only exception to the guide was that I needed to use the command sudo apt -get update before I could make the actual Monodevelop installation, otherwise it wouldn't find the files.

Any help would be highly appreciated!
Thanks
Ola

Re: Switchking on Raspberry Pi

Posted: Mon 03 Mar 2014, 21:18
by erlendfalch
Ola:
I would start to test with setting chmod 777 on the db file. That should give you a indication if it user/group permission related. But remember that it is not advised to use that permission level. So you can probably fix it by a lower level or change/add group memberships.

Re: Switchking on Raspberry Pi

Posted: Sun 23 Mar 2014, 23:23
by Ola
Thanks for the advice. It was actually as easy as re-download and re-install Switchking! Should have tried that before asking..

Re: Switchking on Raspberry Pi

Posted: Fri 02 May 2014, 15:39
by gnagis_99
Suck !
Att det ska vara så omöjligt för en rookie som jag, att installera SK enligt frittefrax eminenta instruktion.
Jag fastnar nu på punkt 6.
Kör : mono /bin/SwitchKing/Bin/SwichKing.exe terminal 8080 8800
så får jag detta felmeddelande "The assembly mscorlib.dll was not found or could not be loaded.
It should have been installed in the `/usr/local/lib/mono/2.0/mscorlib.dll' directory."
Nån som orkar och kan hjälpa mig ? Jag är lost.