Shellies Discovery Script

I asked for the log and you gave me some random screenshots. Please open issue here and fill out a template.

Perhaps a very strange question by absolute HACS beginner…
I installed HACS, when i want to add a integration i do find many of them. But i dont find this shellies discovery script, although documentation states, it should be installable via HACS:
As documentation doesn’t says much more about it, i think, it should be as easy as pressing the + on the integration part of HACS.
Can someone please guide me on gettting this script installed via HACS?

Shellies Discovery is not an integration but a script for python_script component. It’s available on Automations tab in HACS.

I am outing me as a complete noob i think. But i have read the HACS documentation…
I dont see any automations tab in HACS. I see a frontned tab and a integration tab in HACS. No automations tab.

Have you read the documentation?

Have you configured the python_script component?

No. As i have understood the documentation, this was advised to do by a Manual Installation.
I thought, a Installation via hacs should do this by itself.
Documentation is not clear to me at this point

The script requires python_scripts component. If you haven’t configured this component, HACS will not let you install Shellies Discovery.

Thank YOU!
Really, that wasn’t clear to me. Now it works like a charme. Thank you very much.

1 Like

Hi,

I have multiple Shelly devices and I have a custom prefix mqtt configured in the device Advanced - Developer Settings section on each of them.

If you have a custom prefix you must to use this name in automations.yaml instead of shelly name with MAC…

For example, Shellies with the following custom prefix:
H3-Toldo --> Shelly 2.5 like roller
H3-Persiana --> Shelly 2.5 like roller
SALON-LuzSofa --> Shelly Dimmer 2
SALON-LedSofa --> Shelly RGBW2

automations.yaml:

- id: 'shellies_discovery'
  alias: 'Shellies Discovery'
  mode: queued
  max: 999
  trigger:
    platform: mqtt
    topic: shellies/announce
  action:
    service: python_script.shellies_discovery
    data_template:
      id: '{{ trigger.payload_json.id }}'
      mac: '{{ trigger.payload_json.mac }}'
      fw_ver: '{{ trigger.payload_json.fw_ver }}'
      model: '{{ trigger.payload_json.model }}'
      qos: 1
      H3-Toldo:
        mode: "roller"
        roller-0-name: "H3 - Toldo"
        roller-0-class: "awning"
      H3-Persiana:
        mode: "roller"
        roller-0-name: "H3 - Persiana"
        roller-0-class: "blind"
      SALON-LuzSofa:
        light-0-name: "SALON - Luz Sofa"
      SALON-LedSofa:
        light-0-name: "SALON - Led Sofa"
        mode: "rgbw"

Regards

New version: 0.33.0

Changelog:

  • add support for Shelly Motion

Hi, now Ich have time to update to the current release of Shellies discovery script. I received the error after update and restarting the HA again for my shelly gas sensor and only for that.

“…State( File “/usr/src/homeassistant/homeassistant/core.py”, line 871, in init raise InvalidStateError( homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity id: sensor.shelly_gas_50029178b649_rssi. State max length is 255 characters”

What do you need for information?

i have insert the following in my configuration.yaml

configuration.yaml file

logger:
default: warning
logs:
homeassistant.components.python_script: debug
homeassistant.components.automation: info

thanks for your help and regards
Frank

Please show me payload of the topic shellies/shellygas-50029178b649/info

oh my god, can you help me by the syntax :roll_eyes: :sweat_smile:

This is the complete Log entry from Homeassistant

Logger: homeassistant.util.logging
Source: util/logging.py:108
First occurred: 11:20:36 (3 occurrences)
Last logged: 12:00:00

  • Exception in message_received when handling msg on ‘shellies/shellygas-50029178B649/info’: ‘{“wifi_sta”:{“connected”:true,“ssid”:“UniFi”,“ip”:“10.1.3.107”,“rssi”:-69},“cloud”:{“enabled”:false,“connected”:false},“mqtt”:{“connected”:true},“time”:“11:20”,“unixtime”:1606821636,“serial”:4,“has_update”:false,“mac”:“50029178B649”,“cfg_changed_cnt”:0,“actions_stats”:{“skipped”:0},“gas_sensor”:{“sensor_state”:“normal”,“self_test_state”:“completed”,“alarm_state”:“none”},“concentration”:{“ppm”:0,“is_valid”:true},“valves”:[{“state”:“not_connected”}],“update”:{“status”:“idle”,“has_update”:false,“new_version”:“20201124-093005/v1.9.0@57ac4ad8”,“old_version”:“20201124-093005/v1.9.0@57ac4ad8”},“ram_total”:51536,“ram_free”:39660,“fs_size”:233681,“fs_free”:89105,“uptime”:282}’ Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py”, line 35, in wrapper msg_callback(msg) File “/usr/src/homeassistant/homeassistant/components/mqtt/sensor.py”, line 186, in message_received self.async_write_ha_state() File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 296, in async_write_ha_state self._async_write_ha_state() File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 408, in _async_write_ha_state self.hass.states.async_set( File “/usr/src/homeassistant/homeassistant/core.py”, line 1183, in async_set state = State( File “/usr/src/homeassistant/homeassistant/core.py”, line 871, in init raise InvalidStateError( homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity id: sensor.shelly_gas_50029178b649_rssi. State max length is 255 characters.
  • Exception in availability_message_received when handling msg on ‘shellies/shellygas-50029178B649/online’: ‘true’ Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py”, line 35, in wrapper msg_callback(msg) File “/usr/src/homeassistant/homeassistant/components/mqtt/init.py”, line 1202, in availability_message_received self.async_write_ha_state() File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 296, in async_write_ha_state self._async_write_ha_state() File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 408, in _async_write_ha_state self.hass.states.async_set( File “/usr/src/homeassistant/homeassistant/core.py”, line 1183, in async_set state = State( File “/usr/src/homeassistant/homeassistant/core.py”, line 871, in init raise InvalidStateError( homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity id: sensor.shelly_gas_50029178b649_rssi. State max length is 255 characters.
  • Exception in message_received when handling msg on ‘shellies/shellygas-50029178B649/info’: ‘{“wifi_sta”:{“connected”:true,“ssid”:“UniFi”,“ip”:“10.1.3.107”,“rssi”:-71},“cloud”:{“enabled”:false,“connected”:false},“mqtt”:{“connected”:true},“time”:“12:00”,“unixtime”:1606824000,“serial”:4,“has_update”:false,“mac”:“50029178B649”,“cfg_changed_cnt”:0,“actions_stats”:{“skipped”:0},“gas_sensor”:{“sensor_state”:“normal”,“self_test_state”:“completed”,“alarm_state”:“none”},“concentration”:{“ppm”:0,“is_valid”:true},“valves”:[{“state”:“not_connected”}],“update”:{“status”:“idle”,“has_update”:false,“new_version”:“20201124-093005/v1.9.0@57ac4ad8”,“old_version”:“20201124-093005/v1.9.0@57ac4ad8”},“ram_total”:51536,“ram_free”:39492,“fs_size”:233681,“fs_free”:89105,“uptime”:2646}’ Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py”, line 35, in wrapper msg_callback(msg) File “/usr/src/homeassistant/homeassistant/components/mqtt/sensor.py”, line 186, in message_received self.async_write_ha_state() File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 296, in async_write_ha_state self._async_write_ha_state() File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 408, in _async_write_ha_state self.hass.states.async_set( File “/usr/src/homeassistant/homeassistant/core.py”, line 1183, in async_set state = State( File “/usr/src/homeassistant/homeassistant/core.py”, line 871, in init raise InvalidStateError( homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity id: sensor.shelly_gas_50029178b649_rssi. State max length is 255 characters.

Fixed https://github.com/bieniu/ha-shellies-discovery/releases/tag/0.33.1

Hi, thanks for the update. But I received the same message. Maybe I must update to Release 118.n?

Logger: homeassistant.util.logging
Source: util/logging.py:108
First occurred: 13:49:00 (2 occurrences)
Last logged: 13:49:02

  • Exception in message_received when handling msg on ‘shellies/shellygas-50029178B649/info’: ‘{“wifi_sta”:{“connected”:true,“ssid”:“UniFi”,“ip”:“10.1.3.107”,“rssi”:-69},“cloud”:{“enabled”:false,“connected”:false},“mqtt”:{“connected”:true},“time”:“13:49”,“unixtime”:1606830540,“serial”:4,“has_update”:false,“mac”:“50029178B649”,“cfg_changed_cnt”:0,“actions_stats”:{“skipped”:0},“gas_sensor”:{“sensor_state”:“normal”,“self_test_state”:“completed”,“alarm_state”:“none”},“concentration”:{“ppm”:0,“is_valid”:true},“valves”:[{“state”:“not_connected”}],“update”:{“status”:“idle”,“has_update”:false,“new_version”:“20201124-093005/v1.9.0@57ac4ad8”,“old_version”:“20201124-093005/v1.9.0@57ac4ad8”},“ram_total”:51536,“ram_free”:39500,“fs_size”:233681,“fs_free”:89105,“uptime”:9186}’ Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py”, line 35, in wrapper msg_callback(msg) File “/usr/src/homeassistant/homeassistant/components/mqtt/sensor.py”, line 186, in message_received self.async_write_ha_state() File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 296, in async_write_ha_state self._async_write_ha_state() File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 408, in _async_write_ha_state self.hass.states.async_set( File “/usr/src/homeassistant/homeassistant/core.py”, line 1183, in async_set state = State( File “/usr/src/homeassistant/homeassistant/core.py”, line 871, in init raise InvalidStateError( homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity id: sensor.shelly_gas_50029178b649_rssi. State max length is 255 characters.
  • Exception in discovery_callback when dispatching ‘mqtt_discovery_updated_(‘sensor’, ‘shellygas-50029178B649-rssi’)’: ({‘name’: ‘Shelly Gas 50029178B649 RSSI’, ‘state_topic’: ‘shellies/shellygas-50029178B649/info’, ‘force_update’: ‘False’, ‘unique_id’: ‘shellygas-50029178b649-rssi’, ‘qos’: 0, ‘device’: {‘identifiers’: [‘50029178b649’], ‘name’: ‘Shelly Gas 50029178B649’, ‘model’: ‘Shelly Gas’, ‘sw_version’: ‘20201124-093005/v1.9.0@57ac4ad8’, ‘manufacturer’: ‘Allterco Robotics’}, ‘unit_of_measurement’: ‘dB’, ‘device_class’: ‘signal_strength’, ‘value_template’: “{{value_json[‘wifi_sta’].rssi}}”, ‘availability_topic’: ‘shellies/shellygas-50029178B649/online’, ‘payload_available’: ‘true’, ‘payload_not_available’: ‘false’, ‘platform’: ‘mqtt’},) Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/mqtt/init.py”, line 1309, in discovery_callback await self._discovery_update(payload) File “/usr/src/homeassistant/homeassistant/components/mqtt/sensor.py”, line 145, in discovery_update self.async_write_ha_state() File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 296, in async_write_ha_state self._async_write_ha_state() File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 408, in _async_write_ha_state self.hass.states.async_set( File “/usr/src/homeassistant/homeassistant/core.py”, line 1183, in async_set state = State( File “/usr/src/homeassistant/homeassistant/core.py”, line 871, in init raise InvalidStateError( homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity id: sensor.shelly_gas_50029178b649_rssi. State max length is 255 characters.

ok, Thanks :slight_smile: - With HA 118.4 all is fine

Hello!

I’ve upgraded to latest hass.io (HassOS 4.17), latest Home Assistant (0.118.4) and latest Shellies Discovery Script, and now I get the following error:

Logger: homeassistant.components.python_script.shellies_discovery.py
Source: components/python_script/__init__.py:217
Integration: Python Scripts (documentation, issues)
First occurred: 22:14:28 (1 occurrences)
Last logged: 22:14:28

Error executing script: 'NoneType' object is not callable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 217, in execute
    exec(compiled.code, restricted_globals)
  File "shellies_discovery.py", line 448, in <module>
TypeError: 'NoneType' object is not callable

Any ideas?

Post debug log.

1 Like