bieniu / ha-shellies-discovery

Script that adds MQTT discovery support for Shellies devices
Apache License 2.0
290 stars 90 forks source link

RGBW2 white control is gone #355

Closed pjrt closed 1 year ago

pjrt commented 1 year ago

Describe the bug The white control in RGBW2 entities is gone, which means you can no longer control it from HA.

I've read this may be related to a change in 2022.9. https://www.reddit.com/r/homeassistant/comments/x8o96u/shelly_rgbw2_over_mqtt_broken_on_20229/

Expected behavior

The White of the RGBW2 should be controllable.

Versions:

Shellies Discovery automation:

alias: Shellies Discovery
trigger:
  - platform: mqtt
    topic: shellies/announce
action:
  - service: python_script.shellies_discovery
    data:
      id: "{{ trigger.payload_json.id }}"
      mac: "{{ trigger.payload_json.mac }}"
      fw_ver: "{{ trigger.payload_json.fw_ver }}"
      model: "{{ trigger.payload_json.model }}"
      mode: "{{ trigger.payload_json.mode | default }}"
      host: "{{ trigger.payload_json.ip }}"
      shellydw2-E8DB84D24B34:
        expire_after: 86400
      shellydw2-E8DB84D21ED8:
        expire_after: 86400
mode: queued
max: 999

Debug log:

2023-01-06 14:33:16.652 INFO (MainThread) [homeassistant.setup] Setup of domain python_script took 0.1 seconds
2023-01-06 14:33:18.143 INFO (MainThread) [custom_components.hacs] Enable category: python_script
2023-01-06 14:33:25.587 INFO (SyncWorker_2) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellydw2-E8DB84D21ED8', 'mac': 'E8DB84D21ED8', 'fw_ver': '20220209-093605/v1.11.8-g8c7bb8d', 'model': 'SHDW-2', 'mode': '', 'host': '192.168.1.237', 'shellydw2-E8DB84D24B34': {'expire_after': 86400}, 'shellydw2-E8DB84D21ED8': {'expire_after': 86400}}
2023-01-06 14:33:25.859 INFO (SyncWorker_6) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellyrgbw2-A89AF2', 'mac': 'E8DB84A89AF2', 'fw_ver': '20220209-093926/v1.11.8-g8c7bb8d', 'model': 'SHRGBW2', 'mode': 'color', 'host': '192.168.1.139', 'shellydw2-E8DB84D24B34': {'expire_after': 86400}, 'shellydw2-E8DB84D21ED8': {'expire_after': 86400}}
2023-01-06 14:33:26.080 INFO (SyncWorker_2) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellyrgbw2-A890BA', 'mac': 'E8DB84A890BA', 'fw_ver': '20221027-095909/v1.12.1-ga9117d3', 'model': 'SHRGBW2', 'mode': 'color', 'host': '192.168.1.199', 'shellydw2-E8DB84D24B34': {'expire_after': 86400}, 'shellydw2-E8DB84D21ED8': {'expire_after': 86400}}
2023-01-06 14:33:26.609 INFO (SyncWorker_0) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellyrgbw2-DE3731', 'mac': 'E8DB84DE3731', 'fw_ver': '20220809-124336/v1.12-g99f7e0b', 'model': 'SHRGBW2', 'mode': 'color', 'host': '192.168.1.173', 'shellydw2-E8DB84D24B34': {'expire_after': 86400}, 'shellydw2-E8DB84D21ED8': {'expire_after': 86400}}
2023-01-06 14:33:26.881 INFO (SyncWorker_3) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellyswitch25-98F4ABF2F79E', 'mac': '98F4ABF2F79E', 'fw_ver': '20221027-092056/v1.12.1-ga9117d3', 'model': 'SHSW-25', 'mode': 'relay', 'host': '192.168.1.200', 'shellydw2-E8DB84D24B34': {'expire_after': 86400}, 'shellydw2-E8DB84D21ED8': {'expire_after': 86400}}
2023-01-06 14:48:25.812 INFO (MainThread) [homeassistant.components.analytics] Submitted analytics to Home Assistant servers. Information submitted includes {'uuid': '8cde4067e18c4d90bab78420d9303ae7', 'version': '2023.1.1', 'installation_type': 'Home Assistant OS', 'supervisor': {'healthy': True, 'supported': True, 'arch': 'amd64'}, 'operating_system': {'board': 'ova', 'version': '9.4'}, 'certificate': False, 'integrations': ['ssdp', 'script', 'application_credentials', 'shell_command', 'androidtv', 'usb', 'system_log', 'hassio', 'climate', 'mqtt', 'google_translate', 'proxy', 'network', 'history', 'octoprint', 'python_script', 'esphome', 'lock', 'camera', 'universal', 'light', 'dhcp', 'cloud', 'google_assistant', 'webhook', 'schedule', 'scene', 'auth', 'cast', 'search', 'alarm_control_panel', 'group', 'intent_script', 'http', 'update', 'waqi', 'onboarding', 'input_select', 'adguard', 'zha', 'hardware', 'vacuum', 'statistics', 'api', 'wled', 'calendar', 'repairs', 'text', 'input_button', 'amcrest', 'blueprint', 'homeassistant_alerts', 'stream', 'energy', 'accuweather', 'automation', 'my', 'fan', 'counter', 'button', 'darksky', 'file', 'map', 'dialogflow', 'recorder', 'file_upload', 'siren', 'tag', 'input_number', 'timer', 'persistent_notification', 'template', 'default_config', 'humidifier', 'logbook', 'person', 'number', 'proximity', 'smartthings', 'notify', 'ping', 'media_source', 'config', 'configurator', 'websocket_api', 'select', 'cover', 'command_line', 'logger', 'sensor', 'input_boolean', 'upnp', 'homeassistant', 'generic_thermostat', 'ffmpeg', 'tts', 'media_player', 'device_tracker', 'sun', 'switch', 'google', 'bluetooth', 'weather', 'mjpeg', 'tuya', 'trace', 'lovelace', 'analytics', 'input_datetime', 'binary_sensor', 'zone', 'frontend', 'system_health', 'diagnostics', 'input_text', 'image_upload', 'mobile_app', 'switch_as_x', 'time_date', 'zeroconf', 'conversation', 'almond', 'device_automation'], 'custom_integrations': [{'domain': 'hacs', 'version': <AwesomeVersion SemVer '1.29.1'>}, {'domain': 'lutron_caseta_pro', 'version': <AwesomeVersion CalVer '2022.2'>}, {'domain': 'zoom', 'version': <AwesomeVersion SemVer '0.8.4'>}], 'addons': [{'slug': 'a0d7b954_vscode', 'protected': True, 'version': '5.5.1', 'auto_update': False}, {'slug': 'a0d7b954_esphome', 'protected': True, 'version': '2022.3.1', 'auto_update': False}, {'slug': 'core_mosquitto', 'protected': True, 'version': '6.1.3', 'auto_update': False}, {'slug': 'a0d7b954_nodered', 'protected': True, 'version': '14.0.1', 'auto_update': False}, {'slug': 'core_samba', 'protected': True, 'version': '10.0.0', 'auto_update': False}, {'slug': '69bb46cb_dnsomatic', 'protected': True, 'version': '1.1', 'auto_update': False}, {'slug': '8aef3602_dropbox_upload', 'protected': True, 'version': '1.3.0', 'auto_update': False}, {'slug': 'core_rpc_shutdown', 'protected': True, 'version': '2.2', 'auto_update': False}, {'slug': 'cebe7a76_hassio_google_drive_backup', 'protected': True, 'version': '0.109.2', 'auto_update': False}], 'energy': {'configured': True}, 'state_count': 492, 'automation_count': 40, 'integration_count': 123, 'addon_count': 9, 'user_count': 9}
2023-01-06 14:48:40.654 INFO (SyncWorker_7) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellydw2-E8DB84D21ED8', 'mac': 'E8DB84D21ED8', 'fw_ver': '20220209-093605/v1.11.8-g8c7bb8d', 'model': 'SHDW-2', 'mode': '', 'host': '192.168.1.237', 'shellydw2-E8DB84D24B34': {'expire_after': 86400}, 'shellydw2-E8DB84D21ED8': {'expire_after': 86400}}
2023-01-06 15:04:42.144 INFO (SyncWorker_4) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellydw2-E8DB84D21ED8', 'mac': 'E8DB84D21ED8', 'fw_ver': '20220209-093605/v1.11.8-g8c7bb8d', 'model': 'SHDW-2', 'mode': '', 'host': '192.168.1.237', 'shellydw2-E8DB84D24B34': {'expire_after': 86400}, 'shellydw2-E8DB84D21ED8': {'expire_after': 86400}}
2023-01-06 15:23:07.260 INFO (SyncWorker_2) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellydw2-E8DB84D21ED8', 'mac': 'E8DB84D21ED8', 'fw_ver': '20220209-093605/v1.11.8-g8c7bb8d', 'model': 'SHDW-2', 'mode': '', 'host': '192.168.1.237', 'shellydw2-E8DB84D24B34': {'expire_after': 86400}, 'shellydw2-E8DB84D21ED8': {'expire_after': 86400}}
2023-01-06 15:46:51.904 INFO (SyncWorker_6) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellyrgbw2-A89AF2', 'mac': 'E8DB84A89AF2', 'fw_ver': '20220209-093926/v1.11.8-g8c7bb8d', 'model': 'SHRGBW2', 'mode': 'color', 'host': '192.168.1.139', 'shellydw2-E8DB84D24B34': {'expire_after': 86400}, 'shellydw2-E8DB84D21ED8': {'expire_after': 86400}}
2023-01-06 15:46:52.142 INFO (SyncWorker_1) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellyrgbw2-A890BA', 'mac': 'E8DB84A890BA', 'fw_ver': '20221027-095909/v1.12.1-ga9117d3', 'model': 'SHRGBW2', 'mode': 'color', 'host': '192.168.1.199', 'shellydw2-E8DB84D24B34': {'expire_after': 86400}, 'shellydw2-E8DB84D21ED8': {'expire_after': 86400}}
2023-01-06 15:46:52.294 INFO (SyncWorker_0) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellyrgbw2-DE3731', 'mac': 'E8DB84DE3731', 'fw_ver': '20220809-124336/v1.12-g99f7e0b', 'model': 'SHRGBW2', 'mode': 'color', 'host': '192.168.1.173', 'shellydw2-E8DB84D24B34': {'expire_after': 86400}, 'shellydw2-E8DB84D21ED8': {'expire_after': 86400}}
2023-01-06 15:46:52.473 INFO (SyncWorker_7) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellyswitch25-98F4ABF2F79E', 'mac': '98F4ABF2F79E', 'fw_ver': '20221027-092056/v1.12.1-ga9117d3', 'model': 'SHSW-25', 'mode': 'relay', 'host': '192.168.1.200', 'shellydw2-E8DB84D24B34': {'expire_after': 86400}, 'shellydw2-E8DB84D21ED8': {'expire_after': 86400}}
2023-01-06 15:52:52.004 INFO (SyncWorker_6) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellydw2-E8DB84D21ED8', 'mac': 'E8DB84D21ED8', 'fw_ver': '20220209-093605/v1.11.8-g8c7bb8d', 'model': 'SHDW-2', 'mode': '', 'host': '192.168.1.237', 'shellydw2-E8DB84D24B34': {'expire_after': 86400}, 'shellydw2-E8DB84D21ED8': {'expire_after': 86400}}
2023-01-06 15:53:52.547 INFO (SyncWorker_4) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellydw2-E8DB84D21ED8', 'mac': 'E8DB84D21ED8', 'fw_ver': '20220209-093605/v1.11.8-g8c7bb8d', 'model': 'SHDW-2', 'mode': '', 'host': '192.168.1.237', 'shellydw2-E8DB84D24B34': {'expire_after': 86400}, 'shellydw2-E8DB84D21ED8': {'expire_after': 86400}}
pjrt commented 1 year ago

So I see this was removed here: https://github.com/bieniu/ha-shellies-discovery/pull/297 due to the white_value change.

The documentation says it to use COLOR_MODE. https://developers.home-assistant.io/docs/core/entity/light#color-modes

bieniu commented 1 year ago

The given examples use the default MQTT light schema and the script uses the template schema. I don't want to use the default schema because it doesn't support tansition, so this would be a breaking change. Theoretically, we can use JSON schema for RGBW2, but I don't have a device and I'm not able to create a proper configuration. If you provide me a working configuration for the JSON schema, I'll try to implement it in a script.

EDIT: I've read the documentation again and the JSON schema cannot be used for RGBW2.

bieniu commented 1 year ago

Please test the script from this branch https://github.com/bieniu/ha-shellies-discovery/compare/rgbw2-fix

pjrt commented 1 year ago

Got this error:

Exception in discovery_callback when dispatching 'mqtt_discovery_updated_('light', 'shellyrgbw2-A890BA-0')': ({'name': 'Shelly RGBW2 A890BA Light 0', 'availability_topic': 'shellies/shellyrgbw2-A890BA/online', 'payload_available': 'true', 'payload_not_available': 'false', 'command_topic': 'shellies/shellyrgbw2-A890BA/color/0/command', 'state_topic': 'shellies/shellyrgbw2-A890BA/color/0', 'state_value_template': '{{value.lower()}}', 'payload_on': 'on', 'payload_off': 'off', 'rgbw_command_topic': 'shellies/shellyrgbw2-A890BA/color/0/set', 'rgbw_command_template': "{'red':{{red}},'green':{{green}},'blue':{{blue}},'white':{{white}}}", 'rgbw_state_topic': 'shellies/shellyrgbw2-A890BA/color/0/status', 'rgbw_value_template': '{{value_json.red}},{{value_json.green}},{{value_json.blue}},{{value_json.white}}', 'brightness_state_topic': 'shellies/shellyrgbw2-A890BA/color/0/status', 'brightness_value_template': '{{value_json.gain|float|multiply(2.55)|round(0)}}', 'brightness_command_topic': 'shellies/shellyrgbw2-A890BA/color/0/set', 'brightness_command_template': "{'gain':{{value|float|multiply(0.3922)|round(0)}}}", 'effect_command_topic': 'shellies/shellyrgbw2-A890BA/color/0/set', 'effect_command_template': "{ {%if value=='Off'%}'effect':0{%elif value=='Meteor Shower'%}'effect':1{%elif value=='Gradual Change'%}'effect':2{%elif value=='Flash'%}'effect':3{%endif%} }", 'effect_list': ['Off', 'Meteor Shower', 'Gradual Change', 'Flash'], 'effect_state_topic': 'shellies/shellyrgbw2-A890BA/color/0/status', 'effect_value_template': '{%if value_json.effect==1%}Meteor Shower{%elif value_json.effect==2%}Gradual Change{%elif value_json.effect==3%}Flash{%else%}Off{%endif%}', 'unique_id': 'shellyrgbw2-a890ba-light-0', 'qos': 0, 'device': {'connections': [['mac', 'e8:db:84:a8:90:ba']], 'name': 'Shelly RGBW2 A890BA', 'model': 'Shelly RGBW2', 'sw_version': '20221027-095909/v1.12.1-ga9117d3', 'hw_version': 'gen1 (SHRGBW2)', 'manufacturer': 'Allterco Robotics', 'configuration_url': 'http://192.168.1.199/'}, 'platform': 'mqtt'},) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 864, in discovery_callback await self._discovery_update(payload) File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 1057, in discovery_update config: DiscoveryInfoType = self.config_schema()(discovery_payload) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 232, in __call__ return self._exec((Schema(val) for val in self.validators), v) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 355, in _exec raise e if self.msg is None else AllInvalid(self.msg, path=path) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 351, in _exec v = func(v) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__ return self._compiled([], data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable return schema(data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__ return self._compiled([], data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict return base_validate(path, iteritems(data), out) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 433, in validate_mapping raise er.MultipleInvalid(errors) voluptuous.error.MultipleInvalid: required key not provided @ data['command_on_template']
Exception in discovery_callback when dispatching 'mqtt_discovery_updated_('light', 'shellyrgbw2-DE3731-0')': ({'name': 'Shelly RGBW2 DE3731 Light 0', 'availability_topic': 'shellies/shellyrgbw2-DE3731/online', 'payload_available': 'true', 'payload_not_available': 'false', 'command_topic': 'shellies/shellyrgbw2-DE3731/color/0/command', 'state_topic': 'shellies/shellyrgbw2-DE3731/color/0', 'state_value_template': '{{value.lower()}}', 'payload_on': 'on', 'payload_off': 'off', 'rgbw_command_topic': 'shellies/shellyrgbw2-DE3731/color/0/set', 'rgbw_command_template': "{'red':{{red}},'green':{{green}},'blue':{{blue}},'white':{{white}}}", 'rgbw_state_topic': 'shellies/shellyrgbw2-DE3731/color/0/status', 'rgbw_value_template': '{{value_json.red}},{{value_json.green}},{{value_json.blue}},{{value_json.white}}', 'brightness_state_topic': 'shellies/shellyrgbw2-DE3731/color/0/status', 'brightness_value_template': '{{value_json.gain|float|multiply(2.55)|round(0)}}', 'brightness_command_topic': 'shellies/shellyrgbw2-DE3731/color/0/set', 'brightness_command_template': "{'gain':{{value|float|multiply(0.3922)|round(0)}}}", 'effect_command_topic': 'shellies/shellyrgbw2-DE3731/color/0/set', 'effect_command_template': "{ {%if value=='Off'%}'effect':0{%elif value=='Meteor Shower'%}'effect':1{%elif value=='Gradual Change'%}'effect':2{%elif value=='Flash'%}'effect':3{%endif%} }", 'effect_list': ['Off', 'Meteor Shower', 'Gradual Change', 'Flash'], 'effect_state_topic': 'shellies/shellyrgbw2-DE3731/color/0/status', 'effect_value_template': '{%if value_json.effect==1%}Meteor Shower{%elif value_json.effect==2%}Gradual Change{%elif value_json.effect==3%}Flash{%else%}Off{%endif%}', 'unique_id': 'shellyrgbw2-de3731-light-0', 'qos': 0, 'device': {'connections': [['mac', 'e8:db:84:de:37:31']], 'name': 'Shelly RGBW2 DE3731', 'model': 'Shelly RGBW2', 'sw_version': '20221027-095909/v1.12.1-ga9117d3', 'hw_version': 'gen1 (SHRGBW2)', 'manufacturer': 'Allterco Robotics', 'configuration_url': 'http://192.168.1.173/'}, 'platform': 'mqtt'},) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 864, in discovery_callback await self._discovery_update(payload) File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 1057, in discovery_update config: DiscoveryInfoType = self.config_schema()(discovery_payload) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 232, in __call__ return self._exec((Schema(val) for val in self.validators), v) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 355, in _exec raise e if self.msg is None else AllInvalid(self.msg, path=path) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 351, in _exec v = func(v) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__ return self._compiled([], data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable return schema(data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__ return self._compiled([], data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict return base_validate(path, iteritems(data), out) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 433, in validate_mapping raise er.MultipleInvalid(errors) voluptuous.error.MultipleInvalid: required key not provided @ data['command_on_template'] 

I'm trying to see if maybe the issue is that it doesn't set any "supported_color_modes". Not having a lot of luck with it though.