Hello, I followed this thread:
and created a new “Custom Template Sensor” successfully.
I’m able to update the value of the state for this sensor fine:
curl -X POST -H "Authorization: Bearer LONG_LIVED_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"state": "29", "attributes": {"unit_of_measurement": "°C", "friendly_name": "Outdoor Temperature"}}' \
https://{my-homeassistant-url}/api/states/sensor.outdoor_temperature
However, the state gets reset back to empty a few seconds later:
2019-08-10 19:01:39 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.2901368752] Sending {'id': 2, 'type': 'event', 'event': <Event state_changed[L]: entity_id=sun.sun, old_state=<state sun.sun=above_horizon; next_dawn=2019-08-11T02:07:35+00:00, next_dusk=2019-08-10T18:49:52+00:00, next_midnight=2019-08-10T22:27:29+00:00, next_noon=2019-08-11T10:27:32+00:00, next_rising=2019-08-11T02:50:03+00:00, next_setting=2019-08-10T18:07:07+00:00, elevation=16.78, azimuth=273.07, rising=False, friendly_name=Sun @ 2019-08-10T18:49:36.775854+03:00>, new_state=<state sun.sun=above_horizon; next_dawn=2019-08-11T02:07:35+00:00, next_dusk=2019-08-10T18:49:52+00:00, next_midnight=2019-08-10T22:27:29+00:00, next_noon=2019-08-11T10:27:32+00:00, next_rising=2019-08-11T02:50:03+00:00, next_setting=2019-08-10T18:07:07+00:00, elevation=16.2, azimuth=273.88, rising=False, friendly_name=Sun @ 2019-08-10T18:49:36.775854+03:00>>}
2019-08-10 19:01:39 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.outdoor_temperature, old_state=<state sensor.outdoor_temperature=; unit_of_measurement=°C, friendly_name=Outdoor Temperature, icon=mdi:thermometer @ 2019-08-10T19:01:26.011035+03:00>, new_state=<state sensor.outdoor_temperature=29; unit_of_measurement=°C, friendly_name=Outdoor Temperature @ 2019-08-10T19:01:39.812520+03:00>>
2019-08-10 19:01:39 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.2901368752] Sending {'id': 2, 'type': 'event', 'event': <Event state_changed[L]: entity_id=sensor.outdoor_temperature, old_state=<state sensor.outdoor_temperature=; unit_of_measurement=°C, friendly_name=Outdoor Temperature, icon=mdi:thermometer @ 2019-08-10T19:01:26.011035+03:00>, new_state=<state sensor.outdoor_temperature=29; unit_of_measurement=°C, friendly_name=Outdoor Temperature @ 2019-08-10T19:01:39.812520+03:00>>}
2019-08-10 19:01:56 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.outdoor_temperature, old_state=<state sensor.outdoor_temperature=29; unit_of_measurement=°C, friendly_name=Outdoor Temperature @ 2019-08-10T19:01:39.812520+03:00>, new_state=<state sensor.outdoor_temperature=; unit_of_measurement=°C, friendly_name=Outdoor Temperature, icon=mdi:thermometer @ 2019-08-10T19:01:56.014998+03:00>>
2019-08-10 19:01:56 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.2901368752] Sending {'id': 2, 'type': 'event', 'event': <Event state_changed[L]: entity_id=sensor.outdoor_temperature, old_state=<state sensor.outdoor_temperature=29; unit_of_measurement=°C, friendly_name=Outdoor Temperature @ 2019-08-10T19:01:39.812520+03:00>, new_state=<state sensor.outdoor_temperature=; unit_of_measurement=°C, friendly_name=Outdoor Temperature, icon=mdi:thermometer @ 2019-08-10T19:01:56.014998+03:00>>}
I chart for this sensor in the “History” section is just a lot of dots / discrete values rather than a continuous line.
It doesn’t look right to me and any insight into what might be happening here is very welcome.