Description
Make sure you are running the latest version of Home Assistant before reporting an issue.
You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:
Home Assistant release (hass --version
):
container: homeassistant/home-assistant:0.53.1
Python release (python3 --version
):
Python 3.6.2
Component/platform:
Running inside a container using official build, but with . ["python", "-m", "homeassistant", "--config", "/config", "--debug", "--verbose"]
Description of problem:
Getting an exception (TypeError: Object of type 'datetime' is not JSON serializable
) from originating from /usr/src/app/homeassistant/components/splunk.py
, since it tries to do json.dumps(payload)
when payload is: {'host': 'http://splunk....ctor/event', 'event': [{... 'media_position': 0, 'media_position_updated_at': datetime.datetime(2017, 9, 26, 20, 55, 51, 118315, tzinfo=<UTC>), 'media_title': 'a9..bbd3_en_-_google.mp3', '..}, 'time': '2017-09-26 20:55:51.118692+00:00', 'value': 'playing', 'host': 'hass'}]}
Question is.. Is this a bug with the splunk logger not being able to convert it to a string? Or should this have been converted before it was hitting the logger?
This is happening if I try to trigger tts.google_say
.
Expected:
Event being logged as isoformat(), as the other timestamps resulting in no exception.
Problem-relevant configuration.yaml
entries and steps to reproduce:
- Enable splunk and google tts
- Try speaking using google tts
Note that the exception happens before it is able to send the data to splunk, ie, splunk itself is not needed to reproduce.
Traceback (if applicable):
Traceback (most recent call last):
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/app/homeassistant/components/splunk.py", line 84, in splunk_event_listener
requests.post(event_collector, data=json.dumps(payload),
File "/usr/local/lib/python3.6/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/local/lib/python3.6/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/local/lib/python3.6/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/local/lib/python3.6/json/encoder.py", line 180, in default
o.__class__.__name__)
TypeError: Object of type 'datetime' is not JSON serializable
Additional info: