Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recorder - Event not JSON serializable #18900

Closed
cdce8p opened this issue Dec 1, 2018 · 5 comments · Fixed by #19163
Closed

Recorder - Event not JSON serializable #18900

cdce8p opened this issue Dec 1, 2018 · 5 comments · Fixed by #19163

Comments

@cdce8p
Copy link
Member

cdce8p commented Dec 1, 2018

Home Assistant release with the issue: 0.84.0.dev0 (2018-12-01)
Last working Home Assistant release (if known): -
Component/platform: recorder, logbook, persistent_notification, (other?)

Description of problem:
During the execution of persistent_notification.create and logbook.log with templates as message a recorder warning appears (see below).

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

sensor:
  - platform: time_date
    display_options:
      - time

automation:
  - alias: 'Demo'
    initial_state: true
    trigger:
      - platform: homeassistant
        event: start
    action:
      - service: persistent_notification.create
        data_template:
          title: 'Test {{ states("sensor.time") }}'
          message: '**Demo**: {{ states("sensor.time") }}'

Traceback (if applicable):

2018-12-01 22:54:04 WARNING (Recorder) [homeassistant.components.recorder]
  Event is not JSON serializable:
    <Event call_service[L]: domain=persistent_notification, service=create,
      service_data=title=<homeassistant.helpers.template.Template object at 0x7f4561620780>,
      message=<homeassistant.helpers.template.Template object at 0x7f4561620710>>

Additional information:
The template is first rendered during the service call execution. Since we already log the call itself, the error occurs. Might be related to #18720

@point-4ward
Copy link
Contributor

point-4ward commented Dec 6, 2018

Exactly the same problem here. (on 84.b0)

@BudBundi
Copy link

BudBundi commented Dec 7, 2018

Same for telegramnotify

Event is not JSON serializable: <Event call_service[L]: domain=notify, service=telegramnotify,
service_data=message=<homeassistant.helpers.template.Template object at 0x6df93c10>>

and telegram_bot send_message

Event is not JSON serializable: <Event call_service[L]: domain=telegram_bot, service=send_message,
service_data=target=[708054045], message=<homeassistant.helpers.template.Template object
at 0x6f7b1a90>>

@VDRainer
Copy link
Contributor

VDRainer commented Dec 7, 2018

Looks like every notify component is affected.
Seeing this also on iOS and smtp messages.

@cogneato
Copy link

cogneato commented Dec 7, 2018

Also seeing this on 84.0b0 and 84.0b1

Both of these are repeated for persistent notification and service "create"

2018-12-07 12:58:46 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140670539353224] Unable to serialize to JSON: Object of type 'Template' is not JSON serializable
{'id': 2, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'persistent_notification', 'service': 'create', 'service_data': {'title': <homeassistant.helpers.template.Template object at 0x7ff068a50240>, 'message': <homeassistant.helpers.template.Template object at 0x7ff068a50a90>, 'notification_id': 'config_entry_discovery'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2018, 12, 7, 19, 58, 46, 717462, tzinfo=<UTC>), 'context': {'id': '916f3980f2bb4d23980677384e8a37ec', 'user_id': None}}}
2018-12-07 12:58:54 WARNING (Recorder) [homeassistant.components.recorder] Event is not JSON serializable: <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=<homeassistant.helpers.template.Template object at 0x7ff068a50240>, message=<homeassistant.helpers.template.Template object at 0x7ff068a50a90>, notification_id=config_entry_discovery>

@aidbish
Copy link
Contributor

aidbish commented Dec 9, 2018

getting the same kind of errors

2018-12-08 21:56:44 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140627748735072] Unable to serialize to JSON: Object of type 'XiaomiGateway' is not JSON serializable

{'id': 2, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'xiaomi_aqara', 'service': 'stop_ringtone', 'service_data': {'gw_mac': <xiaomi_gateway.XiaomiGateway object at 0x7fe725796898>}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2018, 12, 8, 21, 56, 44, 365576, tzinfo=), 'context': {'id': '27122b8840024516a0d37ad2795825e7', 'user_id': None}}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment