Fixed datetime values (#14153)

pull/14157/head
Gabe 2018-04-28 17:12:40 -05:00 committed by Fabian Affolter
parent 4205dc0f7c
commit 07f94eaa92
1 changed files with 3 additions and 0 deletions

View File

@ -5,6 +5,7 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.sql/
"""
import decimal
import datetime
import logging
import voluptuous as vol
@ -145,6 +146,8 @@ class SQLSensor(Entity):
for key, value in res.items():
if isinstance(value, decimal.Decimal):
value = float(value)
if isinstance(value, datetime.date):
value = str(value)
self._attributes[key] = value
except sqlalchemy.exc.SQLAlchemyError as err:
_LOGGER.error("Error executing query %s: %s", self._query, err)