mirror of
https://github.com/home-assistant/core.git
synced 2025-06-23 22:47:09 +00:00
Fixed datetime values (#14153)
This commit is contained in:
parent
4205dc0f7c
commit
07f94eaa92
@ -5,6 +5,7 @@ For more details about this platform, please refer to the documentation at
|
|||||||
https://home-assistant.io/components/sensor.sql/
|
https://home-assistant.io/components/sensor.sql/
|
||||||
"""
|
"""
|
||||||
import decimal
|
import decimal
|
||||||
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -145,6 +146,8 @@ class SQLSensor(Entity):
|
|||||||
for key, value in res.items():
|
for key, value in res.items():
|
||||||
if isinstance(value, decimal.Decimal):
|
if isinstance(value, decimal.Decimal):
|
||||||
value = float(value)
|
value = float(value)
|
||||||
|
if isinstance(value, datetime.date):
|
||||||
|
value = str(value)
|
||||||
self._attributes[key] = value
|
self._attributes[key] = value
|
||||||
except sqlalchemy.exc.SQLAlchemyError as err:
|
except sqlalchemy.exc.SQLAlchemyError as err:
|
||||||
_LOGGER.error("Error executing query %s: %s", self._query, err)
|
_LOGGER.error("Error executing query %s: %s", self._query, err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user