ChristianKuehnel / plantgateway

Bluetooth to mqtt gateway for Xiaomi Mi plant sensors
Apache License 2.0
276 stars 41 forks source link

Missing TZ in timestamp #38

Open theOrakle opened 5 years ago

theOrakle commented 5 years ago

Add module:

pip3 install python-dateutil

Simply added/modified the following to plantgw.py:

Added import: from dateutil.tz import tzlocal

Modified now() to include tzlocal(): MQTTAttributes.TIMESTAMP.value: datetime.now(tzlocal()).isoformat(),

data['timestamp'] = datetime.now(tzlocal()).strftime(self.config.mqtt_timestamp_format)

jonathantidwell commented 2 years ago

Thanks for this. The 2021.12 update officially broke all of my timestamp entities that didn't have a timezone, including Plant Gateway's. This helped me resolve manually. Would be nice to see something like this change enter the source.