Open diplix opened 5 years ago
lovelace and the newish device_class: timestamp need a timestamp format like this: 2019-07-22T07:26:00+02:00
device_class: timestamp
this could be accomplished by changing the TIME_FORMAT constant in constants.py: TIME_FORMAT = "%Y-%m-%dT%H:%M:%S%z"
TIME_FORMAT
constants.py
TIME_FORMAT = "%Y-%m-%dT%H:%M:%S%z"
however this produces an UTC timezone without colons (which HA needs): 2019-07-22T07:26:00+0200
i’m not very good at python, so i put this into constants.py
TIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
and hard coded this into connector.py and heartbeater.py:
connector.py
heartbeater.py
last_message_fmt = strftime(TIME_FORMAT)+"+02:00"
after that, this works:
- platform: mqtt state_topic: "homeassistant/sensor/kpLastHeartbeat/state" name: kpLastHeartbeat icon: mdi:calendar-clock device_class: timestamp
may be you have a better idea how to do that with datetime.isoformat in python.
datetime.isoformat
lovelace and the newish
device_class: timestamp
need a timestamp format like this: 2019-07-22T07:26:00+02:00this could be accomplished by changing the
TIME_FORMAT
constant inconstants.py
:TIME_FORMAT = "%Y-%m-%dT%H:%M:%S%z"
however this produces an UTC timezone without colons (which HA needs): 2019-07-22T07:26:00+0200
i’m not very good at python, so i put this into
constants.py
TIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
and hard coded this into
connector.py
andheartbeater.py
:last_message_fmt = strftime(TIME_FORMAT)+"+02:00"
after that, this works:
may be you have a better idea how to do that with
datetime.isoformat
in python.