RaZberry: a full featured Z-Wave Home Controller

If you have a question or need help, this is the place to be.
Phil
Experienced User
Posts: 105
Joined: Tue Apr 15, 2014 10:42 am
Location: Merseyside, UK

Re: RaZberry: a full featured Z-Wave Home Controller

Post by Phil » Mon Oct 20, 2014 9:55 am

Hi
I restarted my machine today and have issues with the plug in

Code: Select all

10:52:48      Plugin "RaZBerry Z-Way" is not activated
10:53:02   Error starting plugin: RaZBerry Z-Way
10:53:02   Traceback (most recent call last) (1669):
10:53:02     File "C:\Program Files (x86)\EventGhost\eg\Classes\PluginInstanceInfo.py", line 177, in Start
10:53:02       self.instance.__start__(*self.args)
10:53:02     File "C:\Program Files (x86)\EventGhost\plugins\RaZBerry Z-Way\__init__.py", line 225, in __start__
10:53:02       self.zwave_devices = pickle.load(f)
10:53:02     File "pickle.pyc", line 1405, in load
10:53:02     File "pickle.pyc", line 893, in load
10:53:02     File "pickle.pyc", line 915, in load_eof
10:53:02   EOFError
Any ideas what happened?
I'll sort the other screen shots for the code asap as well, thanks

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: RaZberry: a full featured Z-Wave Home Controller

Post by krambriw » Mon Oct 20, 2014 1:58 pm

If you are running W7 64bit, try first to start EG as admin so that we can rule out that it is a user access problem

Phil
Experienced User
Posts: 105
Joined: Tue Apr 15, 2014 10:42 am
Location: Merseyside, UK

Re: RaZberry: a full featured Z-Wave Home Controller

Post by Phil » Mon Oct 20, 2014 2:27 pm

Hi, same issues running as admin. Its running on w2012 essentials, everything else is fine.

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: RaZberry: a full featured Z-Wave Home Controller

Post by krambriw » Mon Oct 20, 2014 3:13 pm

Well, what goes wrong is in the python module pickle (EOFError). I use if for storing persistent data. The data is stored in a file Razberry.txt normally in Roaming\EventGhost\plugins\Razberry.

Maybe the file is corrupted?

You could try to delete it before you start EG and check if that helps...

BestR

Phil
Experienced User
Posts: 105
Joined: Tue Apr 15, 2014 10:42 am
Location: Merseyside, UK

Re: RaZberry: a full featured Z-Wave Home Controller

Post by Phil » Tue Oct 21, 2014 10:21 am

Yes, getting rid of that file and letting it create a new file has solved it. There is nothing in either the old or new file.

For the devices I have, im not sure what details you need, these are the screenshots off the top (I have no idea why it wont let me correct my typo from senor so sensor!)
one.PNG
two.PNG
thanks for your help with this.

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: RaZberry: a full featured Z-Wave Home Controller

Post by krambriw » Tue Oct 21, 2014 10:54 am

Good to hear, then it is time to start working inside the Raspberry Pi...I use WinSCP

What version of Z-Way do you use? I have the latest 1.7.2

How do you want to send events to EG from Z-Wave? I prefere to use MQTT and I have everything to help you to get that working.

- you have then to install Mosquitto in the RaspBerry (description here http://mosquitto.org/2013/01/mosquitto- ... epository/)
- you have to add the MQTT Client plugin to your EG configuration

Best regards, Walter

PS try also to reach your devices using a standard browser. What you see below we will need later for your setup. As example in my case I use

http://192.168.10.248:8083/ZWaveAPI/Run ... ata[1].val
and as response I get

Code: Select all

{"invalidateTime":1413822704,"updateTime":1413889312,"type":"float","name":"val","value":20.5}
For the typical switch I use
http://192.168.10.248:8083/ZWaveAPI/Run ... data.level
and get

Code: Select all

{"invalidateTime":1413882827,"updateTime":1413882828,"type":"bool","name":"level","value":false}

Phil
Experienced User
Posts: 105
Joined: Tue Apr 15, 2014 10:42 am
Location: Merseyside, UK

Re: RaZberry: a full featured Z-Wave Home Controller

Post by Phil » Tue Oct 21, 2014 11:15 am

Yes I have the same version of z-way
MQTT sounds as good as anything and i've installed mosquitto and the MQTT client.

I can turn my remote socket on and off via a URL, eg for turning the socket on

Code: Select all

http://z-wave:8083/ZWaveAPI/Run/devices%5B3%5D.instances%5B0%5D.commandClasses%5B0x25%5D.Set(255)
with a response of

Code: Select all

null

thanks

Phil
Last edited by Phil on Tue Oct 21, 2014 11:19 am, edited 2 times in total.

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: RaZberry: a full featured Z-Wave Home Controller

Post by krambriw » Tue Oct 21, 2014 11:18 am

Cool, I will prepare the next post with instructions and files that you need to transfer to the Pi

Phil
Experienced User
Posts: 105
Joined: Tue Apr 15, 2014 10:42 am
Location: Merseyside, UK

Re: RaZberry: a full featured Z-Wave Home Controller

Post by Phil » Tue Oct 21, 2014 11:21 am

That's great, thanks.
Out of interest, the range I'm getting on the razberry card is terrible, maybe 2-3metres, do you have the same?

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: RaZberry: a full featured Z-Wave Home Controller

Post by krambriw » Tue Oct 21, 2014 12:05 pm

The following files need to be transferred to your Pi

1) .syscommands needs to be unzipped from .zip into /opt/z-way-server/automation
.zip
(129 Bytes) Downloaded 144 times
2) publish_mqtt.py and mosquitto.py needs to be in /home/Pi/Desktop
publish_mqtt.py
(467 Bytes) Downloaded 110 times
mosquitto.py
(76.22 KiB) Downloaded 115 times
3) the main.js located in /opt/z-way-server/automation needs to be edited to fit your devices and ip to your Pi. The code below is my example and has to be added to end of your main.js. Then edit ip, device and instances etc.

Code: Select all


///////////////////////////////////////////////////////////////////////////////////////////////////
var mqtt_host = '192.168.10.248';
var mqtt_port = 1883;
var mqtt_topic = '/zwave';

function publish_mqtt (eventString, key) {
    try {
        system(
            "python /home/pi/Desktop/publish_mqtt.py",
            mqtt_host,
            mqtt_port,
            mqtt_topic,
            eventString,
            key 
        );
        return;
    } catch(err) {
        debugPrint("Failed to execute script system call: " + err);
    }
}

function switch_binary (device, instance, theValue) {
    device += "";
    instance += "";
    state = 'on';
    key = 255;
    if (theValue == false){
        state = 'off';
        key = 0;
    }
    eventString = 'Device_' + device + '_Instance_' + instance+'_' + state; 
    publish_mqtt(eventString, key);
}

function sensor_binary_temperature (device, instance, theValue) {
    device += "";
    instance += "";
    theValue += "";
    eventString = 'Device_' + device + '_Instance_' + instance + '_temperature';
    publish_mqtt(eventString, theValue);
}

function sensor_binary_input (device, instance, theValue) {
    device += "";
    instance += "";
    theValue += "";
    eventString = 'Device_' + device + '_Instance_' + instance;
    publish_mqtt(eventString, theValue);
}


zway.devices[2].instances[1].SwitchBinary.data.level.bind(function() {
    switch_binary (2, 1, this.value);
 });
 
zway.devices[2].instances[2].SwitchBinary.data.level.bind(function() {
    switch_binary (2, 2, this.value);
 });
 
zway.devices[6].instances[1].commandClasses.SensorBinary.data[1].level.bind(function() {
    sensor_binary_input (6, 1, this.value);
});

zway.devices[6].instances[2].commandClasses.SensorBinary.data[1].level.bind(function() {
    sensor_binary_input (6, 2, this.value);
});

zway.devices[6].instances[3].commandClasses.SensorMultilevel.data[1].val.bind(function() {
    sensor_binary_temperature (6, 3, this.value);
});

zway.devices[6].instances[4].commandClasses.SensorMultilevel.data[1].val.bind(function() {
    sensor_binary_temperature (6, 4, this.value);
});


Once done, restart z-way-server from a Putty session:

Code: Select all

sudo service z-way-server restart

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: RaZberry: a full featured Z-Wave Home Controller

Post by krambriw » Tue Oct 21, 2014 12:24 pm

Out of interest, the range I'm getting on the razberry card is terrible, maybe 2-3metres, do you have the same?
Mine is working better, it is reaching my devices in my house...but I have only two...with some help thru routing via one of my device
Image2.jpg

Phil
Experienced User
Posts: 105
Joined: Tue Apr 15, 2014 10:42 am
Location: Merseyside, UK

Re: RaZberry: a full featured Z-Wave Home Controller

Post by Phil » Tue Oct 21, 2014 1:44 pm

Hi
I think im getting there.
The bit thats new to me with zwave is the device and instances.

I have a multi sensor which I think is device 2, and instance 0 and a switch which i think is device 3 and instance 0, does that sound right?
I presume then for the switch I use

Code: Select all

zway.devices[3].instances[0].SwitchBinary.data.level.bind(function() {
    switch_binary (3, 0, this.value);
});

zway.devices[3].instances[0].SwitchBinary.data.level.bind(function() {
    switch_binary (3, 0, this.value);
});
Then what do I use for the multi sensor?

I presume then if I turn the switch on and off from the web interface I can see it reflected on EG (so long as i opened TCP port 1883 on the firewall)

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: RaZberry: a full featured Z-Wave Home Controller

Post by krambriw » Tue Oct 21, 2014 2:05 pm

Yes, I think you are on the right track

First of all, what is important is that you have the file .syscommands (the name must start with a dot) and that the content is the word 'python'

For your devices, I think it looks ok but for me to check, you need to use the urls described earlier so that I can see if we need to modify/add some of the functions in main.js

If you use the gui, go to 'Device Control' and check the instances (they are inside parenthesis like (#1))

Typically, publish here the response for your devices with a url ending with commandClasses like
http://192.168.10.248:8083/ZWaveAPI/Run ... andClasses

The response in my case is

Code: Select all

{"37":{"name":"SwitchBinary","data":{"invalidateTime":1413822652,"updateTime":1413822653,"type":"NoneType","name":"devices.2.instances.1.commandClasses.37.data","value":null,"supported":{"invalidateTime":1413822652,"updateTime":1413822653,"type":"bool","name":"supported","value":true},"version":{"invalidateTime":1413822652,"updateTime":1413822656,"type":"int","name":"version","value":1},"security":{"invalidateTime":1413822652,"updateTime":1413822653,"type":"bool","name":"security","value":false},"interviewDone":{"invalidateTime":1413822652,"updateTime":1413822657,"type":"bool","name":"interviewDone","value":true},"interviewCounter":{"invalidateTime":1413822652,"updateTime":1413822656,"type":"int","name":"interviewCounter","value":9},"level":{"invalidateTime":1413882827,"updateTime":1413882828,"type":"bool","name":"level","value":false}},"id":37}}
And yes, when everything is working you should expect events in EG when you operate your switches (locally, from web gui, from EG...)

Please double check that you have configured the MQTT Client correctly and that it is listed in the plugin similar to below
Image1.jpg
Image2.jpg

Phil
Experienced User
Posts: 105
Joined: Tue Apr 15, 2014 10:42 am
Location: Merseyside, UK

Re: RaZberry: a full featured Z-Wave Home Controller

Post by Phil » Tue Oct 21, 2014 2:27 pm

Thanks, for some reason the MQTT on eventghost cant talk with the Pi, whether its a mosquitto issue or with the config im not sure.

Code: Select all

15:25:04   Exception in thread Z-Way:
15:25:04   Traceback (most recent call last):
15:25:04     File "threading.pyc", line 532, in __bootstrap_inner
15:25:04     File "C:\Program Files (x86)\EventGhost\plugins\MQTT Client\__init__.py", line 144, in run
15:25:04       mqttc.connect(self.host, self.port, 60, "")
15:25:04     File "C:\Program Files (x86)\EventGhost\plugins\MQTT Client\mosquitto.py", line 569, in connect
15:25:04       return self.reconnect()
15:25:04     File "C:\Program Files (x86)\EventGhost\plugins\MQTT Client\mosquitto.py", line 645, in reconnect
15:25:04       self._sock = socket.create_connection((self._host, self._port))
15:25:04     File "socket.pyc", line 514, in create_connection
15:25:04   error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
15:25:04   

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: RaZberry: a full featured Z-Wave Home Controller

Post by krambriw » Tue Oct 21, 2014 3:26 pm

What happens if you use this command in Putty (in the Pi)?

Code: Select all

sudo /etc/init.d/mosquitto restart

Post Reply