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

Incorrect timestamp format for Home Assistant #59

Closed
m4skime opened this issue Feb 3, 2022 · 1 comment
Closed

Incorrect timestamp format for Home Assistant #59

m4skime opened this issue Feb 3, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@m4skime
Copy link

m4skime commented Feb 3, 2022

Select Add-On (place a lowercase x for the relevant add-on)

  • [ x ] Xiaomi Mi Scale

Describe the bug
the timestamp is not timezoned, so home assistant cannot convert it

To Reproduce
xiaomi mi scale v0.2.7
mqtt 6.0.1
xiaomi composition scale 2
Home assistant 2022.2.0

Expected behaviour
a correct timestamp

Screenshots

Scale (please complete the following information):

  • Name : Mi Body Composition Scale 2
  • Model : XMTZC05HM

Device running Home Assistant (please complete the following information):
-virtual machine

  • usb dongle

Additional context

my sensor configuration :

- platform: mqtt
  name: "Max Derniere pesee"
  state_topic: "miscale/Max/weight"
  value_template: "{{ value_json['timestamp'] }}"
  device_class: timestamp
  icon: mdi:calendar-clock

the logs :

Exception in message_received when handling msg on 'miscale/Max/weight':
'{"weight":109.50,"weight_unit":"kg","bmi":32.34,"basal_metabolism":2038.10,"visceral_fat":27.91,"lean_body_mass":72.78,"body_fat":34.26,"water":46.94,"bone_mass":3.67,"muscle_mass":68.31,"protein":15.45,"body_type":"Thick-set","metabolic_age":56,"timestamp":"2022-01-04 21:39:00.655824"}'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 37, in wrapper msg_callback(msg)
File "/usr/src/homeassistant/homeassistant/components/mqtt/sensor.py", line 280, in message_received self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 530, in async_write_ha_state self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 563, in _async_write_ha_state state = self._stringify_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 536, in _stringify_state if (state := self.state) is None:
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 419, in state raise ValueError( ValueError: Invalid datetime: sensor.max_derniere_pesee provides state '2022-01-04 21:39:00.655824', which is missing timezone information

and

Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:419
Integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 3:06:59 PM (6 occurrences)
Last logged: 3:07:00 PM

Error adding entities for domain sensor with platform mqtt
Error while setting up mqtt platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 614, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 773, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 530, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 563, in _async_write_ha_state
    state = self._stringify_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 536, in _stringify_state
    if (state := self.state) is None:
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 419, in state
    raise ValueError(
ValueError: Invalid datetime: sensor.max_derniere_pesee provides state '2022-01-04 21:39:00.655824', which is missing timezone information
@m4skime m4skime added the bug Something isn't working label Feb 3, 2022
@lolouk44
Copy link
Owner

lolouk44 commented Feb 3, 2022

Thanks. Fixed in 0.2.8

@lolouk44 lolouk44 closed this as completed Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants