binsentsu / am43-ctrl

Node Util for controlling an AM43 Blinds Drive Cover, either over MQTT or via a HTTP API
44 stars 25 forks source link

'value_template' must be set together with 'state_topic' #34

Open provinzio opened 3 years ago

provinzio commented 3 years ago

I updated to the latest am43-ctrl and Home Assistant (supervised) and am now receiving the follow error. I cannot control the blinds anymore.

Any ideas on this? As far as I can see, state_topic is defined with the MQTT message.

2021-06-24 16:06:08 ERROR (MainThread) [homeassistant.util.logging] Exception in async_discover when dispatching 'mqtt_discovery_new_cover_mqtt': ({'name': '0245f32c8f21', 'command_topic': 'homeassistant/cover/0245f32c8f21/set', 'position_topic': 'homeassistant/cover/0245f32c8f21/state', 'set_position_topic': 'homeassistant/cover/0245f32c8f21/setposition', 'position_open': 0, 'position_closed': 100, 'availability_topic': 'homeassistant/cover/0245f32c8f21/connection', 'payload_available': 'Online', 'payload_not_available': 'Offline', 'payload_open': 'OPEN', 'payload_close': 'CLOSE', 'payload_stop': 'STOP', 'value_template': "{{value_json['position']}}", 'unique_id': 'am43_0245f32c8f21_cover', 'device': {'identifiers': 'am43_0245f32c8f21', 'name': '0245f32c8f21', 'manufacturer': 'Generic AM43'}, 'platform': 'mqtt'},)
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
    return schema(data)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/cover.py", line 118, in validate_options
    raise vol.Invalid(
voluptuous.error.Invalid: 'value_template' must be set together with 'state_topic'.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 160, in async_discover
    config = schema(discovery_payload)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 218, in __call__
    return self._exec((Schema(val) for val in self.validators), v)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 341, in _exec
    raise e if self.msg is None else AllInvalid(self.msg, path=path)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 337, in _exec
    v = func(v)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 276, in __call__
    raise er.MultipleInvalid([e])
voluptuous.error.MultipleInvalid: 'value_template' must be set together with 'state_topic'.

Further tries to open/close the blinds will throw the error

2021-06-24 16:07:31 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities cover.0245f32c8f21

I had a second look into the log and the code. It should be regarding the entry at https://github.com/binsentsu/am43-ctrl/blob/master/src/MQTTConnector.js#L51.