giejay / domoticz-gbridge-plugin

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

Add live update with local MQTT and temperature sensor #10

Closed SylvainPer closed 5 years ago

SylvainPer commented 5 years ago

I hope this could help, I enjoy this bevahior as I have some scripts that update my devices and Home didn't see those updates.

giejay commented 5 years ago

Very nice, I will checkout the branch, try it out and merge it if it all works:)

SylvainPer commented 5 years ago

By thinking about it, the thermostat adapter must be reworked on the pushstate but I don't know how yet, I don't have one and don't know what the json from domoticz look like.

giejay commented 5 years ago

You mean the TemperatureAdapter right? I have one and I will do the rework somewhere this weekend.

SylvainPer commented 5 years ago

Exactly. You can look at temperature_sensor_adapter.py but I don't update mode & setpoint. I don't know if a conversion is needed for the mode state names.

giejay commented 5 years ago

Merged and I made the following changes, which are pushed to develop as well:

Fix publishing the state in the temperature adapter and on/off switch adapter Revert logic of determining domoticz_mqtt_used so its also usable when hosting gbridge locally using multiple machines Use the domoticz id instead of the name when determining the adapter when handling domoticz/out messages so it also works for devices which have a different friendlyName (in description) Use adapter.publishState instead of calling self.mqttClient.Publish directly when not using§ domoticz/out topic Only subscribe to domoticz/out when hosting gBridge locally Fix dimmableAdapter publishState not always having an svalue1 inside message

SylvainPer commented 5 years ago

If you're using idx, the problem is that scenes/groups could share the same. I don't know if it's a bug on domoticz side but it could be a problem here.

For the other points, I'm pleased to see your updates. I'll update to test it.

giejay commented 5 years ago

I checked and all my groups and scenes have different id's, are you on the latest domoticz?

SylvainPer commented 5 years ago

Latest beta. I've created a scene for test:

domoticz/out { "LastUpdate" : "2019-04-06 16:03:24", "Name" : "TEst", "Status" : "On", "Timers" : "false", "Type" : "Scene", "idx" : 4 }

and this idx already exist through another hardware (zigate).

SylvainPer commented 5 years ago

I was sawing outside and thought about it, it's a major issue as the plugin use the idx to identify the device with gbridge...

giejay commented 5 years ago

So when you go to devices and sort the devices by index, the same index appears twice?

Edit, I googled and indeed it might be a problem for groups and scenes. Maybe we should prefix the id for groups and scenes?

SylvainPer commented 5 years ago

My device list:

Capture d’écran 2019-04-06 à 16 59 17

A prefix is a good idea. To get the scenes/groups, we can use json.htm?type=scenes to get them and change the parameters on json.htm?type=devices. It implies to update the way the plugin parse the devices.

giejay commented 5 years ago

I have pushed a (possible) fix to Develop

SylvainPer commented 5 years ago

I'll have a look tonight. Maybe we should open an Issue to follow it, the problem is not linked to this PR.

SylvainPer commented 5 years ago

Tested at home, it works. Thanks for the correction !