Hi, I’m new to HA. can you please advise me why I can’t find the integration Shellies Discovery Script?
Shellies Discovery is not an integration, this is a python script.
I spent hours trying to integrate the Shelly Motion 2 in HA. Nothing worked: connection error. Until I came across your Discovery script. Then the Shelly was integrated in five minutes. You are a life saver
I´m trying to get the script for discovery of all my shelly devices running. Being a total newbie I am not sure even how to understand the information in the github page.
What I have done (in my home assistant running in docker container):
- copied the script to /python_scripts (the “hello world” script seems to work)
- found it in developers tools / services
- added the minimal configuration to my configuration.yaml
- rebooted HA several times
I keep on getting the below error in the log file:
Invalid config for [python_script]: expected dict for dictionary value @ data['python_script']. Got [{'id': 'shellies_announce', 'alias': 'Shellies Announce', 'trigger': [{'platform': 'homeassistant', 'event': 'start'}, {'platform': 'time_pattern', 'hours': '/1'}], 'action': {'service': 'mqtt.publish', 'data': {'topic': 'shellies/command', 'payload': 'announce'}}}, {'id': 'shellies_discovery', 'alias': 'Shellies Discovery', 'mode': 'queued', 'max': 999, 'trigger': {'platform': 'mqtt', 'topic': 'shellies/announce'}, 'condition': [{'condition': 'template', 'value_template': '{{ trigger.payloa.... (See /config/configuration.yaml, line 33). Please check the docs at https://www.home-assistant.io/integrations/python_script
I think you added shellies_announce
and shellies_dicovery
automation to the python_script
section. This is wrong! You can add automations in the UI.
Thank you for the clarification @Bieniu. Now I got my shellies gen 1 up and running. Now taking step 2 with gen 2 and then exploring all the wonders of HA.
hi @Bieniu,
maybe you can help with my 2 Shelly EM (fw1.14) & your latest script.
I can see both EM show up in the MQTT integration device list, all good as they are pick up by your script.
but I have 2 problems:
A) I try to select one of them to be used for the energy dashboard, but it is not available in the list.
suggesting an integration issue → Expected data source not listed - Home Assistant
B) the energy value returned by MQTT show anything between 0-0.05kWh (or 0-50Wh when I change the unit, I was expecting more something between 2000-3000Wh of real consumption).
I had those problems long time ago (about a year), I notice it after HA update, but maybe not related, I honestly don’t know. this is why I update everything Shelly to latest with some hope to solve the problem, it doesn’t. As you have a better overview and memory of old version history, you maybe have an idea where I should start to look at, to solve those issues.
Thank for your help.
suggestion (not sure):
entities not defined → see manual integration here Integrating your electricity grid - Home Assistant
‘Make sure you set and provide the device_class
, state_class
, and unit_of_measurement
for those sensors.’ → I have no clue how to modify/complete the right yaml file.
Show me screenshot from MQTT Info section and from Developer Tools → States for this energy sensor.
You didn’t show me the screenshot from MQTT Info.
It seems to me that your configuration comes from the very old version of Shellies Discovery.
very old (I am using your script since 05/2020)-> that is more than probable, that’s happen when you try to update manually the yaml, not understanding all of it…
“”“This script adds MQTT discovery support for Shellies devices.”""
VERSION = “4.5.3”
MQTT info , I was thinking it was the 2nd screen shoot, can’t see what else do you mean by MQTT info
in /config/configuration.yaml I Just have :
Configure Shellies_discovery Python Script
python_script:
in /config/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:
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 }}’
shellyswitch25-C4D816:
mode: roller
shellyswitch25-76C6A0:
mode: roller
shellyswitch25-C4BDA8:
mode: roller
shellyswitch25-C48163:
mode: roller
shellyswitch25-C4D69C:
mode: roller
shellyem-B9E21E:
force_update_sensors: true
shellyem-D26633:
force_update_sensors: true
shelly1pm-B903E8:
ext-temperature-0: true
ext-temperature-1: true
and in /config/python_scripts/shellies_discovery.py
i paste the latest script from github
→ “”“This script adds MQTT discovery support for Shellies devices.”""
VERSION = “4.5.3” …
OK MQTT Info
Shelly EM E868E7D26633 debug info
Payload display
Attempt to parse MQTT messages as JSON
Show as YAML
Entities
- Shelly EM E868E7D26633 Relay 0 (
switch.shelly_em_e868e7d26633_relay_0
)
MQTT discovery data:- Topic:
homeassistant/switch/shellyem-E868E7D26633-relay-0/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/relay/0
10 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Power 0 (
sensor.shelly_em_e868e7d26633_power_0
)
MQTT discovery data:- Topic:
homeassistant/sensor/shellyem-E868E7D26633-power-0/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/relay/0/power
0 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Energy 0 (
sensor.shelly_em_e868e7d26633_energy_0
)
MQTT discovery data:- Topic:
homeassistant/sensor/shellyem-E868E7D26633-energy-0/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/relay/0/energy
0 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Overpower 0 (
binary_sensor.shelly_em_e868e7d26633_overpower_0
)
MQTT discovery data:- Topic:
homeassistant/binary_sensor/shellyem-E868E7D26633-overpower-0/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/relay/0
10 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Firmware Update (
binary_sensor.shelly_em_e868e7d26633_firmware_update
)
MQTT discovery data:- Topic:
homeassistant/binary_sensor/shellyem-E868E7D26633-firmware-update/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/info
10 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Meter Power 0 (
sensor.shelly_em_e868e7d26633_meter_power_0
)
MQTT discovery data:- Topic:
homeassistant/sensor/shellyem-E868E7D26633-emeter-power-0/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/emeter/0/power
10 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Meter Reactive_Power 0 (
sensor.shelly_em_e868e7d26633_meter_reactive_power_0
)
MQTT discovery data:- Topic:
homeassistant/sensor/shellyem-E868E7D26633-emeter-reactive_power-0/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/emeter/0/reactive_power
10 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Meter Voltage 0 (
sensor.shelly_em_e868e7d26633_meter_voltage_0
)
MQTT discovery data:- Topic:
homeassistant/sensor/shellyem-E868E7D26633-emeter-voltage-0/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/emeter/0/voltage
10 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Meter Energy 0 (
sensor.shelly_em_e868e7d26633_meter_energy_0
)
MQTT discovery data:- Topic:
homeassistant/sensor/shellyem-E868E7D26633-emeter-energy-0/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/emeter/0/energy
10 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Meter Returned_Energy 0 (
sensor.shelly_em_e868e7d26633_meter_returned_energy_0
)
MQTT discovery data:- Topic:
homeassistant/sensor/shellyem-E868E7D26633-emeter-returned_energy-0/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/emeter/0/returned_energy
10 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Meter Total 0 (
sensor.shelly_em_e868e7d26633_meter_total_0
)
MQTT discovery data:- Topic:
homeassistant/sensor/shellyem-E868E7D26633-emeter-total-0/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/emeter/0/total
10 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Meter Total_Returned 0 (
sensor.shelly_em_e868e7d26633_meter_total_returned_0
)
MQTT discovery data:- Topic:
homeassistant/sensor/shellyem-E868E7D26633-emeter-total_returned-0/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/emeter/0/total_returned
10 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Meter Power 1 (
sensor.shelly_em_e868e7d26633_meter_power_1
)
MQTT discovery data:- Topic:
homeassistant/sensor/shellyem-E868E7D26633-emeter-power-1/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/emeter/1/power
10 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Meter Reactive_Power 1 (
sensor.shelly_em_e868e7d26633_meter_reactive_power_1
)
MQTT discovery data:- Topic:
homeassistant/sensor/shellyem-E868E7D26633-emeter-reactive_power-1/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/emeter/1/reactive_power
10 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Meter Voltage 1 (
sensor.shelly_em_e868e7d26633_meter_voltage_1
)
MQTT discovery data:- Topic:
homeassistant/sensor/shellyem-E868E7D26633-emeter-voltage-1/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/emeter/1/voltage
10 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Meter Energy 1 (
sensor.shelly_em_e868e7d26633_meter_energy_1
)
MQTT discovery data:- Topic:
homeassistant/sensor/shellyem-E868E7D26633-emeter-energy-1/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/emeter/1/energy
10 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Meter Returned_Energy 1 (
sensor.shelly_em_e868e7d26633_meter_returned_energy_1
)
MQTT discovery data:- Topic:
homeassistant/sensor/shellyem-E868E7D26633-emeter-returned_energy-1/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/emeter/1/returned_energy
10 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Meter Total 1 (
sensor.shelly_em_e868e7d26633_meter_total_1
)
MQTT discovery data:- Topic:
homeassistant/sensor/shellyem-E868E7D26633-emeter-total-1/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/emeter/1/total
10 most recently received message(s)Transmitted messages:
- Shelly EM E868E7D26633 Meter Total_Returned 1 (
sensor.shelly_em_e868e7d26633_meter_total_returned_1
)
MQTT discovery data:- Topic:
homeassistant/sensor/shellyem-E868E7D26633-emeter-total_returned-1/config
- PayloadSubscribed topics:
shellies/shellyem-E868E7D26633/online
- Topic:
10 most recently received message(s)
shellies/shellyem-E868E7D26633/emeter/1/total_returned
10 most recently received message(s)Transmitted messages:
Triggers
No triggers
Your configuration is definitely from an old version of Shelly Discovery. If you are sure you have the latest version of the script installed, you will probably find in the log why it is not working properly.
log are talking
Logger: homeassistant.components.python_script.shellies_discovery.py
Source: components/python_script/init.py:224
Integration: Python Scripts (documentation, issues)
First occurred: October 7, 2023 at 12:03:26 AM (520 occurrences)
Last logged: 9:00:06 PM
Error executing script: host value None is not valid, update shellies_discovery automation
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/python_script/init.py”, line 224, in execute
exec(compiled.code, restricted_globals) # noqa: S102
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “shellies_discovery.py”, line 1524, in
ValueError: host value None is not valid, update shellies_discovery automation
Now, you know what you have to do.
confused…
the only automation I got is in /config/automations.yaml
can’t find anything like “shellies_discovery automation”
ok moving forward, miss that last line "host …
now the log are clear for that part ;-))
but I got a new “greamlins” → MQTT entity name starts with the device name in your config {‘name’: 'Shelly 2.5 … and need FW 1.13 ->1.14
that’s for tomorrow …
Thank you @Bieniu for your help