freakent / dbus-mqtt-devices

A driver for Victron VenusOS GX devices to support use of dbus-mqtt/flashmq-mqtt
MIT License
111 stars 24 forks source link

Help needed with OpenHab sending JSON #25

Closed Joeknx closed 1 year ago

Joeknx commented 1 year ago

Thank you for the great tool. Exactly what I need.

I have a working keep alive rule (DSL rule)

val actions = getActions("mqtt", "mqtt:broker:VenusOS") actions.publishMQTT("R/xxxxxxxx/keepalive", '["grid/40/Ac/Frequency", "grid/40/Ac/Energy/Forward"]') logInfo("Solar", "CCGX MQTT Keep Alive Timer fired!!")

I can't manage to send the JSON

Example: actions.publishMQTT(„device/fe001/Status“, '[{ "clientId": "fe001", "connected": 1, "version": "v1.0 ALPHA", "services": {"t1": "temperature"} }]')

...is not working.

actions.publishMQTT(„device/fe001/Status“, '{ "clientId": "fe001", "connected": 1, "version": "v1.0 ALPHA", "services": {"t1": "temperature"} }')

also not.

freakent commented 1 year ago

Can I just confirm status following your last message? You said you can not send JSON? So is this now working or not?

In your example:

actions.publishMQTT(„device/fe001/Status“, '[{ "clientId": "fe001", "connected": 1, "version": "v1.0 ALPHA", "services": {"t1": "temperature"} }]') You have incorrectly surrounded the payload in array square brackets. the payload is an object not an array.

Joeknx commented 1 year ago

It is working now. Thank you! val actions = getActions("mqtt", "mqtt:broker:VenusOS") actions.publishMQTT("device/fe001/Status", '{ "clientId": "fe001", "connected": 1, "version": "v1.0 ALPHA", "services": {"t1": "temperature"} }')

But i am still struggling with the value. actions.publishMQTT("W/XXXXXX/temperature/<device instance>/Temperature", '{"value": 24.91}')

What is the device instance? t1?

Thank you!

freakent commented 1 year ago

No, the device instance is the number you get back from the dbus by sending the registration message. You need to subscribe to device/<client id>/DBus before you publish the connect message. Please read the registration protocol section within the docs.

Joeknx commented 1 year ago

Thank you. It is working now. I tried to understand the readme, but did not quit get it.

Sorry for the beginner questions!

freakent commented 1 year ago

No problem. I'm glad you got it working. I'm always happy to receive suggestions that improve the documentation.