zivillian / ism7mqtt

GNU General Public License v3.0
49 stars 8 forks source link

some json topics for write not working #102

Closed alexkno79 closed 3 months ago

alexkno79 commented 3 months ago

I consider changing from separate topics to json topics for receiving and writing. For writing I even have a use case: when changing partymodus or urlaubsmodus several things need to be send: The mode itself (on/off), the start time, start date, end time and end date. I noticed that sometimes the values when sending them separated seem to be overwritten shortly after setting them b wolf. I guess it happens when the times change in wolf itself while the seperate topics are still processed. So I wanted to send them in one json topic in order to have them in one shot.

When testing the writing I noticed that some topics I use with values to topics do not work with json.

For example setting the partymodus and urlaubsmodus times and dates.

e.g I receive the following topic BM-2_0x35:

{
  "Uhrzeit":"00:13:00",
  "Datum":"22/03/2024 00:00:00",
  "Partymodus":{"value":0,"text":"Deaktiviert"},
  "Urlaubsmodus":{"value":0,"text":"Deaktiviert"},
  "1x Warmwasser":{"value":0,"text":"Aus"},
  "Freigabe SmartHome":{"value":0,"text":"Aus"},
  "Au\u00DFentemperatur":7.2,
  "Uhrzeit Ende":{"330000":"03:12:00","330006":"03:12:00"},
  "Datum Ende":{"330001":"22/03/2024 00:00:00","330007":"22/03/2024 00:00:00"},
  "Uhrzeit Start":{"330002":"00:12:00","330008":"00:12:00"},
  "Datum Start":{"330003":"22/03/2024 00:00:00","330009":"22/03/2024 00:00:00"},
  "Uhrzeit BM2":"00:13:00",
  "Datum BM2":"22/03/2024 00:00:00"
}

as you can see the part for end times is: "Uhrzeit Ende":{"330000":"03:12:00","330006":"03:12:00"}

Sending this now to ism7mqtt as: {"Uhrzeit Ende":{"330000":"10:42:00","330006":"10:42:00"}} I see in the log that it's not accepted:

received mqtt with topic 'Wolf/192.168.178.64/BM-2_0x35/set' '{"Uhrzeit Ende":{"330000":"10:42:00","330006":"10:42:00"}}'
nothing to send for topic 'Wolf/192.168.178.64/BM-2_0x35' with payload '{"Uhrzeit Ende":{"330000":"10:42:00","330006":"10:42:00"}}'

Setting for example the status of partymodus works fine and is accepted and processed: {"Partymodus":{"value":0,"text":"Deaktiviert"}}

Also sending the topic for Uhrzeit Ende as value to topic works fine, but not sending the json.

Any idea what goes wrong?

zivillian commented 3 months ago

After looking at the code this looks like a bug. The README even has an example for how to publish via json to duplicated properties.

The easy fix for you would be to remove one of the duplicated parameters from the parameter.json - this will change the structure of the json (since there are no longer multiple parameter ids) but then you should be able to publish json like {"Uhrzeit Ende":"10:42:00"}.

Since this is a documented feature, I would like to also support json for duplicated parameters - so it would be great if you could share your config and maybe also validate the fix - even if you go the easy way and just remove one of the duplicated parameters.

To be able to reproduce and fix this I would need your parameter.json and the debug log of the initial requests (and responses) so I can emulate your setup.

alexkno79 commented 3 months ago

parameter_v15short.json debuglog.txt

Thanks for looking into it! Log and parameter.json (I already stripped out several parameters) attached.

Deleting one of the parameters mentioned is unfortunately not really an option (besides for testing purposes). Both represent different data points I need. One is the end time for Urlaubsmodus the other one for Partymodus. And in fact the same applies also for uhrzeit Start, Datum Ende and Datum Start.

Of course I stand ready for tests. Thanks again

zivillian commented 3 months ago

I've found and (hopefully) fixed the issue. Can you try again with the binaries from https://github.com/zivillian/ism7mqtt/actions/runs/8401995751#artifacts

alexkno79 commented 3 months ago

Seems to work! Thanks a lot:

received mqtt with topic 'Wolf/192.168.178.64/BM-2_0x35/set' '{"Uhrzeit Ende":{"330000":"10:42:00","330006":"10:42:00"}}'
> <?xml version="1.0" encoding="utf-16"?><tbreq xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" bn="6" gw="1" ae="true" ty="write"><iwr se="" ba="0x30" in="10151" dl="0x2A" dh="0x0A" /><iwr se="" ba="0x30" in="10146" dl="0x2A" dh="0x0A" /></tbreq>
< <?xml version="1.0" encoding="utf-8"?><tbres bn="6" gw="" st="OK" ts="2024-03-23T15:27:44" emsg=""><iac se="0" ba="0x30" in="10151" dl="0x2A" dh="0xA" st="OK"/><iac se="0" ba="0x30" in="10146" dl="0x2A" dh="0xA" st="OK"/></tbres>
publishing mqtt with topic 'Wolf/192.168.178.64/BM-2_0x35' '{"Uhrzeit Ende":{"330000":"10:42:00","330006":"10:42:00"}}'