giejay / domoticz-gbridge-plugin

Domoticz plugin for the Kappelt gBridge
16 stars 4 forks source link

no support for temperature / thermostat #3

Closed JurikRistjouw closed 5 years ago

JurikRistjouw commented 5 years ago

I've added a temperature sensors and a thermostat device, but i get these errors from domoticz log:

2018-12-14 11:16:50.930 Error: (kapelt gBridge) No gBridge adapter found for device: Room Temperature 2018-12-14 11:16:50.930 Error: (kapelt gBridge) No gBridge adapter found for device: Living Room Thermostat

according to the docs, it should work. Is this a bug or not yet implemented?

kind regards,

Jurik

JurikRistjouw commented 5 years ago

Device count is correct now and no more double thermostat. Thanx for fixing and explaining!

giejay commented 5 years ago

With the 2 latest commits, you can now ask what the temperature in the room is, and also if a light/switch is on :)

It still says that the room is off (something to do with the heat mode?) but it does tell you the temperature.

TheReptile commented 5 years ago

The latest update breaks gBridge. On startup of Domoticz:

2018-12-27 21:00:19.285 Error: (gBridge) 'onStart' failed 'JSONDecodeError'.
2018-12-27 21:00:19.285 Error: (gBridge) ----> Line 157 in '/home/pi/domoticz/plugins/gbridge/plugin.py', function onStart
2018-12-27 21:00:19.285 Error: (gBridge) ----> Line 71 in '/home/pi/domoticz/plugins/gbridge/plugin.py', function onStart
2018-12-27 21:00:19.285 Error: (gBridge) ----> Line 77 in '/home/pi/domoticz/plugins/gbridge/plugin.py', function syncDevices
2018-12-27 21:00:19.285 Error: (gBridge) ----> Line 48 in '/home/pi/domoticz/plugins/gbridge/gbridge_client.py', function fetchDevicesFromBridge
2018-12-27 21:00:19.285 Error: (gBridge) ----> Line 319 in '/usr/lib/python3.5/json/__init__.py', function loads
2018-12-27 21:00:19.285 Error: (gBridge) ----> Line 339 in '/usr/lib/python3.5/json/decoder.py', function decode
2018-12-27 21:00:19.285 Error: (gBridge) ----> Line 357 in '/usr/lib/python3.5/json/decoder.py', function raw_decode 

When using a voice command:


2018-12-27 21:04:12.803 Error: (gBridge) 'onMessage' failed 'TypeError':'argument of type 'NoneType' is not iterable'.
2018-12-27 21:04:12.803 Error: (gBridge) ----> Line 178 in '/home/pi/domoticz/plugins/gbridge/plugin.py', function onMessage
2018-12-27 21:04:12.803 Error: (gBridge) ----> Line 100 in '/home/pi/domoticz/plugins/gbridge/plugin.py', function onMessage
2018-12-27 21:04:12.803 Error: (gBridge) ----> Line 126 in '/home/pi/domoticz/plugins/gbridge/mqtt.py', function onMessage
2018-12-27 21:04:12.803 Error: (gBridge) ----> Line 135 in '/home/pi/domoticz/plugins/gbridge/plugin.py', function onMQTTPublish
2018-12-27 21:04:12.854 Error: (gBridge) 'onMessage' failed 'TypeError':'argument of type 'NoneType' is not iterable'.
2018-12-27 21:04:12.854 Error: (gBridge) ----> Line 178 in '/home/pi/domoticz/plugins/gbridge/plugin.py', function onMessage
2018-12-27 21:04:12.854 Error: (gBridge) ----> Line 100 in '/home/pi/domoticz/plugins/gbridge/plugin.py', function onMessage
2018-12-27 21:04:12.854 Error: (gBridge) ----> Line 126 in '/home/pi/domoticz/plugins/gbridge/mqtt.py', function onMessage
2018-12-27 21:04:12.854 Error: (gBridge) ----> Line 135 in '/home/pi/domoticz/plugins/gbridge/plugin.py', function onMQTTPublish
2018-12-27 21:04:14.003 Status: MySensors: Using serial port: /dev/ttyUSB1
JurikRistjouw commented 5 years ago

With the 2 latest commits, you can now ask what the temperature in the room is, and also if a light/switch is on :)

It still says that the room is off (something to do with the heat mode?) but it does tell you the temperature.

That sounds awesome! But I think you mean setpoint there? So I can ask what the current setpoint is.. temperature was not supported and I therefor have no temp sensors added. Could you confirm the code is breaking at this point?

JurikRistjouw commented 5 years ago

@giejay would it be possible to have a development branch in git? so we can switch back to master if it breaks in the future?

giejay commented 5 years ago

@JurikRistjouw Yes I can make a develop branch.

@TheReptile For me everything works, on my local setup and the hosted gBridge. I've added debug logging in the latest commit, can you pull, update and show me the url which is printed: 'Calling API: http://www'. Off course, enable debug logging;)

JurikRistjouw commented 5 years ago

@giejay awesome! I will try the latest commit. looking forward to the development branch

TheReptile commented 5 years ago

@giejay Ok, seems I found the configuration error. In my settings I had https://gbridge.kappelt.net/ (with trailing /). That broke the communication. After I removed the / everything worked. Something must have changed, since this worked before.

JurikRistjouw commented 5 years ago

ok, pulled latest commit (include action in debug logging). Nothing breaks, but after push and sync twice, I get unable to reach thermostat or devices are off (when they are on)

giejay commented 5 years ago

When do you get that response? What do you ask?

JurikRistjouw commented 5 years ago

when asking: what is the temperature in the living room: unable to reach the "device name" when asking what lights are on in the attic: the x and y are off. (should be on)

EDIT, the thermostat was added as device to the living room in GH When asking, set the living room temp to 20.5 degrees, it responds: you got it, settting the "device name" to 20.5 degrees

giejay commented 5 years ago

Did you first turn on the temperature and the lights through Google? That's needed for now, until I built in a timer to update statuses in gBridge/google every x minutes.

JurikRistjouw commented 5 years ago

I did not set a temp when rebooted. I guess i've done it now because it works. Now i can raise and lower the temp as well as get a setpoint back. I say close the issue for now, or does it need work to respond on the manual overrides?

edit btw, it has some cache issues still. i've set the setpoint to 18. asked to raise by 0.1 (setpoint is 18.1 in domoticz now) when asking what is the current temp. it responds 18. it should have responded 18.1.

giejay commented 5 years ago

that might be a rounding issue, do you get the same behavior as setting 18 to 19?

JurikRistjouw commented 5 years ago

check, when setting a full degree by voice it responds and operates correctly. only when settings by hand it does not transfer to gbridge and thus the temp is at the previous (gbridge aware) setpoint. As you said it is at this point. Thus far, it is as good is at is can be i guess. cheers!

JurikRistjouw commented 5 years ago

btw, i switched to the develop branch! thanx

giejay commented 5 years ago

Thanks to the PR of Sylvain i could integrate support for pushing back temperature changes to the "set" topic, also if the temp wasn't changed through gBridge but through Domoticz for example. So this should now fully work, can you test?

JurikRistjouw commented 5 years ago

@giejay I will pull, test and let you know the results.

JurikRistjouw commented 5 years ago

well domoticz crashed on me after resetting the branch and pulling the latest commit. Any advice? should i clear the __pycache directory or do something else?

up and running again after a reboot... keep you posted

JurikRistjouw commented 5 years ago

It seems the temp can be set with voice, but is not returned when asked. It looks like it reads out the current temperature, instead of the setpoint. I don't know how to differentiate. I tried, setpoint and thermostat with no luck. Only temperature can be asked. Also not updated when set with domoticz. But maybe that is due to the fact, it reads out the current temp instead of the setpoint...

giejay commented 5 years ago

Did you add the mqtt plugin to domoticz hardware?

JurikRistjouw commented 5 years ago

well, it was still there? should i readd it?

giejay commented 5 years ago

No I mean the MQTT Client Gateway with LAN interface hardware. This is now used for returning the values to gBridge.

JurikRistjouw commented 5 years ago

I am not sure what you mean. I have the kapelt gbridge account with mqtt from the beginning. Should i add another?

giejay commented 5 years ago

Go to the hardware page and add the MQTT Client Gateway hardware using the same mqtt host and port as you are using gBridge

JurikRistjouw commented 5 years ago

not sure what you want me to do, I already have the kapelt gbridge in domoticz. Do i have to add another account or just refresh the current mqtt plugin from domoticz by disabling and re-enabling the device?

anyway I get errors, see next post

JurikRistjouw commented 5 years ago

2019-04-07 00:08:30.194 Error: (kapelt gBridge) 'onMessage' failed 'TypeError':''int' object is not subscriptable'. 2019-04-07 00:08:30.194 Error: (kapelt gBridge) ----> Line 198 in '/home/pi/domoticz/plugins/domoticz-gbridge-plugin/plugin.py', function onMessage 2019-04-07 00:08:30.194 Error: (kapelt gBridge) ----> Line 105 in '/home/pi/domoticz/plugins/domoticz-gbridge-plugin/plugin.py', function onMessage 2019-04-07 00:08:30.194 Error: (kapelt gBridge) ----> Line 126 in '/home/pi/domoticz/plugins/domoticz-gbridge-plugin/mqtt.py', function onMessage 2019-04-07 00:08:30.194 Error: (kapelt gBridge) ----> Line 166 in '/home/pi/domoticz/plugins/domoticz-gbridge-plugin/plugin.py', function onMQTTPublish 2019-04-07 00:08:30.194 Error: (kapelt gBridge) ----> Line 37 in '/home/pi/domoticz/plugins/domoticz-gbridge-plugin/adapters/on_off_switch_adapter.py', function publishState 2019-04-07 00:08:30.216 Error: (kapelt gBridge) 'onMessage' failed 'TypeError':''int' object is not subscriptable'. 2019-04-07 00:08:30.216 Error: (kapelt gBridge) ----> Line 198 in '/home/pi/domoticz/plugins/domoticz-gbridge-plugin/plugin.py', function onMessage 2019-04-07 00:08:30.216 Error: (kapelt gBridge) ----> Line 105 in '/home/pi/domoticz/plugins/domoticz-gbridge-plugin/plugin.py', function onMessage 2019-04-07 00:08:30.217 Error: (kapelt gBridge) ----> Line 126 in '/home/pi/domoticz/plugins/domoticz-gbridge-plugin/mqtt.py', function onMessage 2019-04-07 00:08:30.217 Error: (kapelt gBridge) ----> Line 166 in '/home/pi/domoticz/plugins/domoticz-gbridge-plugin/plugin.py', function onMQTTPublish 2019-04-07 00:08:30.217 Error: (kapelt gBridge) ----> Line 37 in '/home/pi/domoticz/plugins/domoticz-gbridge-plugin/adapters/on_off_switch_adapter.py', function publishState

giejay commented 5 years ago

Whats the incoming message thats appearing in the debug line just above the error?

giejay commented 5 years ago

I have updated the readme, can you check if you executed step 6 correctly?

JurikRistjouw commented 5 years ago

Whats the incoming message thats appearing in the debug line just above the error?

not related to kapelt gbridge, differs with reboots. This time it is a failed login attempt to solaredge.

JurikRistjouw commented 5 years ago

I have updated the readme, can you check if you executed step 6 correctly?

will do

JurikRistjouw commented 5 years ago

@giejay I don't use a local mqtt server. I use the one from kapelt. Not sure how to do step 6

giejay commented 5 years ago

Ah sorry, should have started with that:)

Maybe if we ask @peterkappelt nicely, he can reserve some space (with ACL) for "domoticz/out/{userid}" in his MQTT broker :) Then it would also work for the remote gBridge.

For now, I discovered a bug when not using the local domoticz topic so that might explain why its not working for you. I have fixed the bug and will test it tonight when Im home.

SylvainPer commented 5 years ago

If you can host a mqtt server, this can be a solution: https://doc.gbridge.io/firstSteps/mqttServer.html#using-own-mosquitto-as-a-bridge

giejay commented 5 years ago

If we could add extra parameters to the plugin (which is not possible due to the limit of 6), we could add an extra local MQTT server for separating the domoticz/out vs the gbridge topic. Maybe a PR on Domoticz to make the limit go away:)

SylvainPer commented 5 years ago

Yes, it will avoid the test on the server name that is not the better way...

SylvainPer commented 5 years ago

Another way could be two branches on github, not the best way but it'll work.

JurikRistjouw commented 5 years ago

I have someone magically install the "proxy" mqtt (thanx for that the one who's name cannot be mentioned) and it works!! it reads out the status correctly now. Being really critical, I would be nice to see it differentiate when asking the set-point or temperature. Now it reacts to set temperature, and it will set the set-point. But i guess that is an issue with gbridge itself?

@giejay fantastic work! thanx

giejay commented 5 years ago

No thats not an issue with gBridge, thats an issue in this code:

 if 'svalue1' in message:
            temp = self.get_temperature(message['svalue1'], device)
            topic = topic + '/' + str(message['idx'])
            mqtt_client.Publish(topic + '/tempset-ambient/set', temp)
            mqtt_client.Publish(topic + '/tempset-setpoint/set', temp)

I will fix this as well by checking the message for a type (hopefully) like Setpoint vs temperature.

JurikRistjouw commented 5 years ago

@giejay Awesome! This thread keeps getting better and better! Waiting patiently

giejay commented 5 years ago

I pushed my changes to develop.

One thing I noticed that my Temperature + Setpoint devices are split up for my Tado Thermostat, so I should actually also mark the Temp device as a "gBridge" device and probably give it a slightly different name to be able to query the room temperature.

JurikRistjouw commented 5 years ago

pulled and rebooted, have the same issue as you. I added the temp sensor of the thermostat also. Both have a setpoint now... not sure how to name them. will test further.

SylvainPer commented 5 years ago

The problem is as they are split, you create 2 devices. I think there are several possibilities:

JurikRistjouw commented 5 years ago

i concur that it is impossible for gbridge/plugin to know which is which. And no way in google to differentiate. Both are registered as temp devices.

SylvainPer commented 5 years ago

Google is not the problem, there is a way to ask: https://doc.gbridge.io/traits/temperaturesetting.html The plugin is not yet able to manage it but as it's software, we have to find a solution.

I don't have a thermostat for the moment, I've a dedicated arduino that works perfectly so I don't know how many devices you have. Three ? one for the mode, one for the ambient and one for the setpoint ?

giejay commented 5 years ago

I have introduced a feature called "LinkedDevices"

Add linkedDevices:{indexOfDevice} to the description, for example: linkedDevices:13 to the device with index 12 (the thermostat). The index 13 is the Temperature device. This results in:

2019-04-06 23:56:31.477 (gBridge) MQTT message: domoticz/out {'svalue3': '1', 'idx': 13, 'stype': 'WTGR800', 'id': '3', 'nvalue': 0, 'svalue2': '50', 'svalue1': '22.1', 'description': '', 'dtype': 'Temp + Humidity', 'RSSI': 12, 'name': 'Thuis Woonkamer TempHum', 'unit': 0, 'Battery': 255} 2019-04-06 21:56:31.478 (gBridge) MqttClient::Publish gBridge/u1/12/tempset-ambient/set (22.1) 2019-04-06 21:56:31.479 (gBridge) MqttClient::Publish gBridge/u1/12/tempset-humidity/set (50)

Fixed:)

Btw, you can add multiple linked devices, so for device 11: linkedDevices:12,17,20.

All messages for 12,17 and 20 will be handled by the handler for the device 11

JurikRistjouw commented 5 years ago

pfoe, another plugin... sounds like a meme ;) at this point i have the temp set device and temp read device from the thermostat added to gbridge.

image

EDIT: deleted the second device after @giejay comment and testing

giejay commented 5 years ago

Another plugin? What do you mean? You dont need another plugin for this feature

JurikRistjouw commented 5 years ago

linkedDevices:13

Will try that feature! added the ID of the temp senor to the thermostat on a new line after the friendly name.

JurikRistjouw commented 5 years ago

is the second id (the senor) supposed to be exposed for gbridge? and if so, what name

I can set the temp, but when asking the temperature it states that the living heating is unreachable...

how do you ask for setpoint versus reading out the temp?