Open christoferjh opened 5 years ago
Hi, hosted is not supported: if you are hosting gBridge locally and you want to the values pushed back to Google (so you can ask, Hey Google, is the light on?), add the MQTT Client Gateway with LAN interface to your hardware, see third screenshot
Not sure I understand? Is it not supported to update state if I use https://gbridge.kappelt.net/? The singular reason I pay is to not need to config and do local hosting?
I dont think I understand you, your lights are turning on and off right? When doing it directly in Domoticz? But you want the state in gBridge so you can query, hey google, is my light on?
Exactly! It works to turn lights on and off from gBridge. As I understand gBridge keeps a cache of the state, I guess that cache isn't updated from domoticz via this plugin?
Correct. Only when using the local hosted gBridge, that works.
Okay, but is it possible to push the state some other way? Or is it that the hosted version doesn't allow state updating? It looks like it should work by going domoticz -> nod-red -> gBridge, but I guess the limitation is in the hosted version since it could work from this plugin similarly by just forward the changes?
That would involve subscribing to multiple topics, the local domoticz topic, on which all changes are pushed (and then forwarded to gbridge) and subscribing to the remote one. Could be done, maybe Ill dive into it this weekend.
Just checking, do you have a local MQTT broker running?
Yes, that's how I communicate with mysensors and node-red.
So I tried subscribing to multiple MQTT brokers but it seems Domoticz doesnt like that very much. Im getting a lot of errors. You can try it for yourself by checking out this branch: https://github.com/giejay/domoticz-gbridge-plugin/tree/feature/multiple-mqtt-brokers
You can komma separate the brokers like: mqtt.gbridge.io:1883,192.168.2.17:1883
It needs the local one to have anonymous login.
Did you try to use your local MQTT server as bridge ? It's explained here : https://doc.gbridge.io/firstSteps/mqttServer.html#using-own-mosquitto-as-a-bridge I didn't tested it but as I understand it, the distant gbridge MQTT server become a client to the local MQTT server and all the messages are seen locally. This should work without any code modification but the gbridge plugin configuration must be changed to local. @giejay do you think this might work ?
Yes that might work indeed!
@christoferjh could you try this configuration ? If it works, a section on the readme would be helpful.
Previous posts are a long time ago but I'am still using this plugin with a local gbridge. Also trying to get the status working with a bridge. But there is a problem in the plugin why it is not working.
I use friendly names for a device. For example in the description "gBridge:opladen" of a switch device. So the topic in my case is: gBridge/u1/opladen/onoff and switch on/off the device from google is working. But I see the status is published in gBridge/u1/59/onoff/set. So the idx of the device is used and not the friendly name. That is why it is not working I think.
I'am not very familiar with Python but I see I have to change this in de corresponding adapter. But how?
Hi,
Here you can change the id to a friendly name: https://github.com/giejay/domoticz-gbridge-plugin/blob/master/adapters/on_off_switch_adapter.py#L40
And for other adapters I guess the same thing should be done
Thanks. Yes I discovered this already. But because of lack of Python experience I do not see how I can retrieve the friendly name. I also think at that place you do not know if you have to use the friendly name or the idx.
Just replace idx on line 44 with friendlyName or name, not sure which one Domoticz exposes. That is the correct place for publishing new statuses.
friendlyName is not a domoticz device thing. It is in the description after gBridge: friendlyname.
But I found another solution and now status is working.
I changed:
def publishState(self, mqtt_client, device, base_topic, value):
base_topic = base_topic + '/' + str(self.determineDeviceIdOrName(device)) + '/onoff/set'
mqtt_client.Publish(base_topic, value)
And added:
def determineDeviceIdOrName(self, device):
if "gBridge" in device['Description']:
match = re.search('gBridge:(.*)([\n|\r]?)', device['Description'])
if match:
res = match.group(1).strip()
else:
res = device['idx']
else:
res = device['idx']
return res
When switching on or off light in domoticz, the state is not sent. Nothing shown in logs. The other way works (can use google to turn lights on and off). Can create new lights from domotics, ping works. What am I doing wrong? Pretty sure this have worked. Using hosted.