You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am looking at value type implementation in CanPI.py.
At line 81-83 the value taken from commands_hpsu.json is fitted into a single byte (two hex nibbles)
but further investigation is needed because I am not exactly aware of how different "value_code" maps to different message bytes.
I also tried merging the "value_code" fix from Spanni26:master in my current HEAD (segaura:logrevision).
This is for setting values and I also tried to implement the possible corresponding code for reading values.
What I experiment is that the value_code dictionaries are needed in the original order in the read operation.
I am talking of rows around line 500 in pyHPSU.py
if not setValue:
response = n_hpsu.parseCommand(cmd=c, response=rc, verbose=verbose)
resp = n_hpsu.umConversion(cmd=c, response=response, verbose=verbose)
if c["value_code"] is None:
arrResponse.append({"name":c["name"], "resp":resp, "timestamp":response["timestamp"]})
else:
arrResponse.append({"name":c["name"], "resp":resp, "timestamp":response["timestamp"],"desc":dict(map(reversed, c["value_code"].items()))[resp]})
this adds an additional desc field to output JSON for the value description, when applicable, like this
given this, I think we can consider other things (e.g. readability? something else?) to decide which order is better, because this "set and read" use case works with any order and needs both orders ...so far I don't mind, both orders are equally fine for me.
I can add everything to my current pull request #44, but the new "desc" field in the output can be harmful for someone, maybe breaking automations: for this sake I only have included it in JSON output cases (e.g. the CLI output and the MQTT output when timestamp is added) and also wait for some discussion about this.
The text was updated successfully, but these errors were encountered:
I am looking at
value
type implementation inCanPI.py
.At line 81-83 the value taken from
commands_hpsu.json
is fitted into a single byte (two hex nibbles)this does not work with values bigger than 255.
For instance the command
compose the message
breking things, because
friday
equals1280
(0x0500
).I tried to solve this with this code
but further investigation is needed because I am not exactly aware of how different "value_code" maps to different message bytes.
I also tried merging the "
value_code
" fix from Spanni26:master in my current HEAD (segaura:logrevision).This is for setting values and I also tried to implement the possible corresponding code for reading values.
What I experiment is that the
value_code
dictionaries are needed in the original order in the read operation.I am talking of rows around line 500 in
pyHPSU.py
this adds an additional
desc
field to output JSON for the value description, when applicable, like thisand with the inverted
value_code
dictionary you introducedit is still necessary to have it reversed, like this
given this, I think we can consider other things (e.g. readability? something else?) to decide which order is better, because this "set and read" use case works with any order and needs both orders ...so far I don't mind, both orders are equally fine for me.
I can add everything to my current pull request #44, but the new "desc" field in the output can be harmful for someone, maybe breaking automations: for this sake I only have included it in JSON output cases (e.g. the CLI output and the MQTT output when timestamp is added) and also wait for some discussion about this.
The text was updated successfully, but these errors were encountered: