issue-91: Return the raw value instead of "None" in the __str__ method of the data fields#92
Conversation
|
Is this only relevant for the |
|
In |
Ok, that makes sense. However, I'm wondering: How is a normal API consumer (e.g. the Home Assistant integration) supposed to deal with if from_heatpump(...):With your change, you now have to check if a value from the options has been returned or some other integer, etc. This makes it less usable for an API consumer. If I understand you correctly the actual go is to improve debugging / reverse engineering. Shouldn't we use some logging in that case? Unfortunately it seems like no logger is available, but this shouldn't be too hard. |
|
I would wonder if homeassistant does anything other than print the raw value. To use the value in your example you have to write If to_heatpump(...):
Value = to_heatpump(...)Better would be Value = to_heatpump(...)
If Value:But then you could use If isinstance(Value, str):to ensure that value is of type Another solution could be to implement a Or return str(value)then the return value would always be of type string. |
ea5e0a0 to
0b0ea95
Compare
|
Then let's go with the proposed In any case, probably this will break some test cases? |
|
I see you are not happy with these changes. I will try to solve this differently. |
4655bb1 to
4f9fe8e
Compare
|
Please checkout the new solution: |
…nd. The string representation now outputs the raw value if the user value is 'None'.
1d743f2 to
8e0f9be
Compare
8e0f9be to
04c8e2b
Compare
…_str__ representation
If the selection value is unknown, output the raw value instead of None to simplify the "reverse engineering".
fixes #91
Update:
Summary of the changes:
Basenow stores the raw value instead of the already converted "user value"Base.Rawto set and get the stored raw value directlyBase.Valueto get the stored raw value converted tothe "user value"Base.Valueto set the stored value by a "user value" which is converted to raw dataBase.__str__now output the raw value if the "user value" is Nonedump-luxtronik.pynow uses the string representation of the data field class