Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] last_reset move into set_state, too #288

Closed
unl0ck opened this issue Dec 16, 2024 · 5 comments
Closed

[BUG] last_reset move into set_state, too #288

unl0ck opened this issue Dec 16, 2024 · 5 comments

Comments

@unl0ck
Copy link
Contributor

unl0ck commented Dec 16, 2024

Describe the bug
I missed to expand the set_state in sensor for set last_reset if set Total

SOrry for this

@unl0ck
Copy link
Contributor Author

unl0ck commented Dec 17, 2024

@unixorn i have to set the last_reset in set_state or ?
how will it send via mqtt ? maybe i missed more to add

https://developers.home-assistant.io/docs/core/entity/sensor/#state-class-sensorstateclasstotal

@unl0ck
Copy link
Contributor Author

unl0ck commented Dec 24, 2024

@unixorn sorry bro I made a mistake, how can I test it in front of ?

File "/usr/local/lib/python3.12/site-packages/ha_mqtt_discoverable/sensors.py", line 337, in set_state self._state_helper(str(state), last_reset=last_reset) File "/usr/local/lib/python3.12/site-packages/ha_mqtt_discoverable/__init__.py", line 749, in _state_helper message_info = self.mqtt_client.publish(topic, state, retain=retain) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 1247, in publish raise TypeError( TypeError: payload must be a string, bytearray, int, float or None. Exception in thread Thread-62 (historical_data_task): Traceback (most recent call last): File "/usr/local/lib/python3.12/threading.py", line 1073, in _bootstrap_inner self.run() File "/usr/local/lib/python3.12/threading.py", line 1010, in run self._target(*self._args, **self._kwargs) File "/build/GridboxConnector/__main__.py", line 59, in historical_data_task ha_viessmann_historical_device.update_sensors(total, midnight_today.isoformat()) File "/build/GridboxConnector/ha_viessmann_gridbox_connector.py", line 106, in update_sensors self.production_sensor.set_state(measurement.get("production", ""), last_reset=last_reset) File "/usr/local/lib/python3.12/site-packages/ha_mqtt_discoverable/sensors.py", line 337, in set_state self._state_helper(str(state), last_reset=last_reset) File "/usr/local/lib/python3.12/site-packages/ha_mqtt_discoverable/__init__.py", line 749, in _state_helper message_info = self.mqtt_client.publish(topic, state, retain=retain)

@unl0ck
Copy link
Contributor Author

unl0ck commented Dec 24, 2024

I will push after Christmas an bug fix :( I am so sorry.

@unl0ck
Copy link
Contributor Author

unl0ck commented Dec 26, 2024

#294 @unixorn pushed fix with added unit test now it should working

@unl0ck unl0ck closed this as completed Jan 2, 2025
@unixorn
Copy link
Owner

unixorn commented Jan 8, 2025

Thanks for your help improving the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants