esphome / esphome-core

🚨 No longer used 🚨 - The C++ framework behind ESPHome
https://esphome.io/
GNU General Public License v3.0
545 stars 113 forks source link

TypeError in Home Assistant when using homeassistant text sensor #368

Closed pauln closed 5 years ago

pauln commented 5 years ago

Operating environment/Installation (Hass.io/Docker/pip/etc.):

ESP (ESP32/ESP8266/Board/Sonoff):

WaveShare e-Paper ESP8266 Driver Board (using esp12e board config)

Affected component:

Home Assistant text sensor

Description of problem: I was thrilled to see that esphomelib supports the WaveShare e-ink/e-paper displays, and dove in to get my 7.5" panel up and running as an ambient display for my Home Assistant instance. I haven't yet managed to get any state data though, as Home Assistant (0.85.0) throws a TypeError when it tries to set the state in the protobuf message.

Problem-relevant YAML-configuration entries:

text_sensor:
  - platform: homeassistant
    name: "Temperature"
    entity_id: sensor.temperature_probe
    id: temperature_test

Traceback (if applicable):

(from Home Assistant logs)

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/google/protobuf/internal/python_message.py", line 526, in init
    setattr(self, field_name, field_value)
  File "/usr/local/lib/python3.6/site-packages/google/protobuf/internal/python_message.py", line 662, in field_setter
    new_value = type_checker.CheckValue(new_value)
  File "/usr/local/lib/python3.6/site-packages/google/protobuf/internal/type_checkers.py", line 177, in CheckValue
    raise TypeError(message)
TypeError: <state sensor.temperature_probe=25.5; battery_level=5.0, unit_of_measurement=°C, friendly_name=Temperature, device_class=temperature @ 2019-01-11T13:29:19.213525+13: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/local/lib/python3.6/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 "/usr/local/lib/python3.6/site-packages/aioesphomeapi/client.py", line 748, in send_home_assistant_state
    state=state,
  File "/usr/local/lib/python3.6/site-packages/google/protobuf/internal/python_message.py", line 528, in init
    _ReraiseTypeErrorWithFieldName(message_descriptor.name, field_name)
  File "/usr/local/lib/python3.6/site-packages/google/protobuf/internal/python_message.py", line 448, in _ReraiseTypeErrorWithFieldName
    six.reraise(type(exc), exc, sys.exc_info()[2])
  File "/usr/local/lib/python3.6/site-packages/six.py", line 692, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.6/site-packages/google/protobuf/internal/python_message.py", line 526, in init
    setattr(self, field_name, field_value)
  File "/usr/local/lib/python3.6/site-packages/google/protobuf/internal/python_message.py", line 662, in field_setter
    new_value = type_checker.CheckValue(new_value)
  File "/usr/local/lib/python3.6/site-packages/google/protobuf/internal/type_checkers.py", line 177, in CheckValue
    raise TypeError(message)
TypeError: <state sensor.temperature_probe=25.5; battery_level=5.0, unit_of_measurement=°C, friendly_name=Temperature, device_class=temperature @ 2019-01-11T13:29:19.213525+13:00> has type <class 'homeassistant.core.State'>, but expected one of: (<class 'bytes'>, <class 'str'>) for field HomeAssistantStateResponse.state

Additional information: I tried to extract individual properties of the state by setting the entity_id to (for example) sensor.temperature_probe.battery_level, but then esphomeyaml complains that Entity ID must have exactly one dot in it - so it doesn't seem possible to work around it in this manner.

OttoWinter commented 5 years ago

Fixed in next HA release