Hello, I’m trying to use esphomelibs homeassistant sensor component with the new Native API. From looking at the esphomelib source code, it appears the only difference between the homeassistant sensor and text_sensor componnent is a parse_float function. I then assume if the state of an entity is numeric, I can use an entity from any hass domain (not just sensor.*) However I cannot get either component to work. NaN is displayed on my ESP display. Esphomelib yaml throws no errors. The input_slider is set up properly and works in homeassistant. Other components are presented properly from esphomelib to homeassistant.
In esphomelibyaml:
sensor:
- platform: homeassistant
name: “Temperature Sensor From Home Assistant”
entity_id: input_number.temp
id: hass_temp
display:
- platform: …
…
printf(“Temp: %.0f”, id(hass_temp).state);
HomeAssistant logs:
TypeError: <state input_number.temp=70.0; friendly_name=Temperature, mode=slider, initial=68.0, max=78.0, min=62.0, step=1.0 @ 2019-01-15T06
:56:08.316522-05:00> has type <class ‘homeassistant.core.State’>, but expected one of: (<class ‘bytes’>, <class ‘str’>) for field HomeAssist
antStateResponse.state
2019-01-15 06:56:14 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/google/protobuf/internal/python_message.py”, line 526, in init
setattr(self, field_name, field_value)
File “/srv/homeassistant/lib/python3.5/site-packages/google/protobuf/internal/python_message.py”, line 662, in field_setter
new_value = type_checker.CheckValue(new_value)
File “/srv/homeassistant/lib/python3.5/site-packages/google/protobuf/internal/type_checkers.py”, line 177, in CheckValue
raise TypeError(message)
TypeError: <state input_number.temp=68.0; friendly_name=Temperature, mode=slider, initial=68.0, max=78.0, min=62.0, step=1.0 @ 2019-01-15T06:56:14.747540-05:00> has type <class ‘homeassistant.core.State’>, but expected one of: (<class ‘bytes’>, <class ‘str’>)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/esphome/init.py”, line 215, in send_home_assistant_state
await cli.send_home_assistant_state(entity_id, new_state)
File “/srv/homeassistant/lib/python3.5/site-packages/aioesphomeapi/client.py”, line 748, in send_home_assistant_state
state=state,
File “/srv/homeassistant/lib/python3.5/site-packages/google/protobuf/internal/python_message.py”, line 528, in init
_ReraiseTypeErrorWithFieldName(message_descriptor.name, field_name)
File “/srv/homeassistant/lib/python3.5/site-packages/google/protobuf/internal/python_message.py”, line 448, in _ReraiseTypeErrorWithFieldName
six.reraise(type(exc), exc, sys.exc_info()[2])
File “/srv/homeassistant/lib/python3.5/site-packages/six.py”, line 692, in reraise
raise value.with_traceback(tb)
File “/srv/homeassistant/lib/python3.5/site-packages/google/protobuf/internal/python_message.py”, line 526, in init
setattr(self, field_name, field_value)
File “/srv/homeassistant/lib/python3.5/site-packages/google/protobuf/internal/python_message.py”, line 662, in field_setter
new_value = type_checker.CheckValue(new_value)
File “/srv/homeassistant/lib/python3.5/site-packages/google/protobuf/internal/type_checkers.py”, line 177, in CheckValue
raise TypeError(message)
TypeError: <state input_number.temp=68.0; friendly_name=Temperature, mode=slider, initial=68.0, max=78.0, min=62.0, step=1.0 @ 2019-01-15T06:56:14.747540-05:00> has type <class ‘homeassistant.core.State’>, but expected one of: (<class ‘bytes’>, <class ‘str’>) for field HomeAssistantStateResponse.state