softypit / esp32_mqtt_eq3

esp32-based mqtt node to control EQ-3 BLE TRVs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Not connected" - How to configure?

Bonscha opened this issue · comments

I just spent two hours trying to fuígure out why the ESP32 says it's "not connected". Nevermind - it just connected itself for unknown reasons, after I didn't change anything.

The remaining problem with OH3 is that there seems to be no communication with this device. Can anyone help me out with an example configuration from Openhab 3? OH3 thinks everything works, but it was never able to send commands and after initially I got updates via MQTT, that stopped working. Using the ESP32 UI, I can control the EQ3 device...

edit:
After I configured the ESP32 with "mqtt://openhabian:1883" (added the port), I can again see MQTT telegrams when the ESP32 UI has been used to send a command. I comes in at around 5-10 seconds after "sending" the command via UI - also the EQ3 device updates teh display status at around that time.
What I cannot do is get the values out of that string, and also I cannot use OH3 to send any telegrams...

2022-04-15 15:44:31.201 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EQ3Stellantriebe_StellantriebeListe' changed from {"devices":[{"rssi":-82,"bleaddr":"00:1A:22:1A:85:BE"}]} to {"devices":[{"rssi":-81,"bleaddr":"00:1A:22:1A:85:BE"}]} 2022-04-15 15:44:57.535 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'EQ3Stellantriebe_EQ3SchlafzimmerSollTemperatur' received command 25 2022-04-15 15:44:57.547 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'EQ3Stellantriebe_EQ3SchlafzimmerSollTemperatur' predicted to become 25 2022-04-15 15:44:57.556 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EQ3Stellantriebe_EQ3SchlafzimmerSollTemperatur' changed from 19 to 25 2022-04-15 15:46:41.695 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EQ3Stellantriebe_StellantriebeStatus' changed from {"trv":"00:1A:22:1A:85:BE","temp":"20.0","offsetTemp":"0.0","valve":"89% open","mode":"manual","boost":"inactive","window":"closed","state":"unlocked","battery":"GOOD"} to {"trv":"00:1A:22:1A:85:BE","temp":"26.0","offsetTemp":"0.0","valve":"0% open","mode":"manual","boost":"inactive","window":"closed","state":"unlocked","battery":"GOOD"} 2022-04-15 15:47:17.494 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EQ3Stellantriebe_StellantriebeStatus' changed from {"trv":"00:1A:22:1A:85:BE","temp":"26.0","offsetTemp":"0.0","valve":"0% open","mode":"manual","boost":"inactive","window":"closed","state":"unlocked","battery":"GOOD"} to {"trv":"00:1A:22:1A:85:BE","temp":"20.0","offsetTemp":"0.0","valve":"0% open","mode":"manual","boost":"inactive","window":"closed","state":"unlocked","battery":"GOOD"}

After I somehow managed to understand it needs JSON conversion to put/read strings to/from the correct payload slots, I just need help with a correct JSON conversion template for OH3. Why is this not documented anywhere?

If someone can give me an example so I can work it out, I'll write an extensive wiki entry about OH3 integration... -.-

commented

It is important to understand the way the valves operate with regard to BLE signalling. This is basically the way the mqtt command/status mechanism works.
i.e. you send a command like set-temperature or boost and the trv sends back a response with the full current status of all parameters. This obviously doesn't map directly to OH items so some translation work is required.
The json structure is defined in the readme.md file. Each of the parameters could be mapped directly to an OH item provided the facility exists within OH3 to achieve this from a json object.
You can also confirm the exact json status payload returned after each command by looking at the status log on the ESP32 gui.

To send a command you need to publish to the command topic with a message payload containing the BLE address of the valve and the command and any parameters.
topic is '/radin/trv' where mqttid is the id configured on the ESP32.
The message would be '00:1A:22:1A:85:BE settemp 22.0' to set the temperature to 22.0 degrees.

To do this from the command line as a test use:
mosquitto_pub -h -p 1883 -t "radin/trv" -m "00:1A:22:1A:85:BE settemp 22.0"

Thanks for clarification this far.

Before, I tried with:
transformationPatternOut: JSONPATH:$.[?(trv=='00:1A:22:1A:85:BE')].settemp
Which didn't do anything...

I understand that I don't have to use JSONpath conversion for sending - I can just use "formatBeforePublish" and it sends a command which is also received correctly by the device:
formatBeforePublish: 00:1A:22:1A:85:BE settemp %s

After getting the control to work, I rewrote the JSONpath for incoming telegrams to:
transformationPattern: JSONPATH:$.temp
This works and I get the temp feedback. Since now the MAC address is missing, though, I'd suspect when having several devices online, the values won't be able to get matched to the correct points in OH3...?

I don't seem able to "pick" the ID-related values only, though - my transformation pattern including the ID (see above) produces errors, even though it's valid in the online evaluator: http://jsonpath.com/

edit:

I just bought another EQ3 valve actuator and tried out what happens if it sends feedback.

2022-04-16 18:29:58.159 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EQ3Bridge_HeizungSchlafzimmerStatus' changed from {"trv":"00:1A:22:1A:85:BE","temp":"17.0","offsetTemp":"0.0","valve":"0% open","mode":"auto","boost":"inactive","window":"closed","state":"unlocked","battery":"GOOD"} to {"trv":"00:1A:22:1A:84:05","temp":"21.0","offsetTemp":"0.0","valve":"0% open","mode":"auto","boost":"inactive","window":"closed","state":"unlocked","battery":"GOOD"}

How can I filter for the correct MAC address with JSONpath? I tried and it didn't work out, even though the evaluator says it's correct...

commented

I've not worked with JSONpath before (or OH3) but I have played with OH2 rules - would something like the following work as a rule?
you may need to manipulate the 'valve' string to remove the colons ':' if OH3 doesn't like them in an item name

rule "Handle EQ3 status"
when
Item EQ3_status_json changed
then
val valve = transform("JSONPATH", "$.trv", EQ3_status_json.state.toString)
val temp = transform("JSONPATH", "$.temp", EQ3_status_json.state.toString)

// Assume temperature setting item for this valve is "00:1A:22:1A:84:05-settemp"
postUpdate(valve+"-settemp",temp)
// Update any other items associated with this trv here
val mode = transform("JSONPATH", "$.mode", EQ3_status_json.state.toString)
postUpdate(valve+"-mode",mode)

end

Thanks, that did the trick! I adapted the script a little, since OH3 doesn't let me name the items with ":", so I cannot use the MAC addresses, but no problem. I do parse the whole string and send updates specifically to all existing items. This way, It does work fine and gets matched correctly to the respective device's items.

Since I'm on vacation the next week, I will write an extensive wiki entry on how to implement in Openhab 3, including flashing ESP32 for dummies... Thanks for the help so far. I'd leave this issue open until documented in the wiki, if that is okay for you. :)

image

Here is my parsing script (DSL script):


  val trv = transform("JSONPATH", "$.trv", EQ3Bridge_EQ3Status.state.toString)
  val temp = transform("JSONPATH", "$.temp", EQ3Bridge_EQ3Status.state.toString)
  val offsettemp = transform("JSONPATH", "$.offsettemp", EQ3Bridge_EQ3Status.state.toString)
  val valve = transform("JSONPATH", "$.valve", EQ3Bridge_EQ3Status.state.toString)
  val mode = transform("JSONPATH", "$.mode", EQ3Bridge_EQ3Status.state.toString)
  val boost = transform("JSONPATH", "$.boost", EQ3Bridge_EQ3Status.state.toString)
  val window = transform("JSONPATH", "$.window", EQ3Bridge_EQ3Status.state.toString) 
  val state = transform("JSONPATH", "$.state", EQ3Bridge_EQ3Status.state.toString)
  val battery = transform("JSONPATH", "$.battery", EQ3Bridge_EQ3Status.state.toString)

// match trv MAC address to respective OH3 items and send updates
  
//Schlafzimmer
  if (trv == "00:1A:22:1A:85:BE") {
    postUpdate("Heizung_Schlafzimmer_Solltemperatur_Status",temp)
    postUpdate("Heizung_Schlafzimmer_Mode_Status",mode)
    postUpdate("Heizung_Schlafzimmer_Ventilstellung_Status",valve)
      //Wohnzimmer
  } else if (trv == "00:1A:22:1A:84:05") {
    postUpdate("Heizung_Wohnzimmer_Solltemperatur_Status",temp)
    postUpdate("Heizung_Wohnzimmer_Mode_Status",mode)
    postUpdate("Heizung_Wohnzimmer_Ventilstellung_Status",valve)
  }

First draft for wiki entries is ready here: https://docs.google.com/document/d/1Hkb8LttefBZPBlLxWwad50e2exZTauphOs8B9PFYjnc/edit?usp=sharing

Feel free to use that for this wiki or anywhere else, to prevent questions like mine in the future... ;)