For Shelly 3EM, the script registers power
, reactive power
, voltage
, energy
, returned energy
, total
and total returned
sensors for every meter.
Hi, I canât get to work. Mqtt shows no integration. Broker working, receives back details after announcement, but home assistant is not creating entities. Discovery_prefix: homeassistant
What should I look for?
2020-06-27 11:27:36 INFO (MainThread) [homeassistant.components.automation] Shellies Discovery: Executing step call service,
2020-06-27 11:27:36 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event automation_triggered[L]: name=Shellies Discovery, entity_id=automation.shellies_discovery>,
2020-06-27 11:27:36 INFO (MainThread) [homeassistant.components.automation] Executing Shellies Discovery,
2020-06-27 11:27:36 INFO (MainThread) [homeassistant.components.automation] Shellies Discovery: Running script,
2020-06-27 11:27:37 DEBUG (SyncWorker_4) [homeassistant.components.python_script.shellies_discovery.py] id: shellydimmer2-E0980695AF0D, mac: e0980695af0d, fw_ver: 20200528-111028/1026-new-device-dimmer-l@98d7122e,
2020-06-27 11:27:37 INFO (SyncWorker_4) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellydimmer2-E0980695AF0D', 'mac': 'E0980695AF0D', 'fw_ver': '20200528-111028/1026-new-device-dimmer-l@98d7122e'},
2020-06-27 11:27:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.2916923888] Sending {'id': 2, 'type': 'event', 'event': <Event state_changed[L]: entity_id=automation.shellies_discovery, old_state=<state automation.shellies_discovery=on; last_triggered=2020-06-26T19:21:41.667966+03:00, id=shellies_discovery, friendly_name=Shellies Discovery @ 2020-06-26T19:10:02.512492+03:00>, new_state=<state automation.shellies_discovery=on; last_triggered=2020-06-27T11:27:36.671584+03:00, id=shellies_discovery, friendly_name=Shellies Discovery @ 2020-06-26T19:10:02.512492+03:00>>},
2020-06-27 11:27:36 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=python_script, service=shellies_discovery, service_data=id=shellydimmer2-E0980695AF0D, mac=E0980695AF0D, fw_ver=20200528-111028/1026-new-device-dimmer-l@98d7122e>,
2020-06-27 11:27:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.2916994608] Sending {'id': 2, 'type': 'event', 'event': <Event state_changed[L]: entity_id=automation.shellies_discovery, old_state=<state automation.shellies_discovery=on; last_triggered=2020-06-26T19:21:41.667966+03:00, id=shellies_discovery, friendly_name=Shellies Discovery @ 2020-06-26T19:10:02.512492+03:00>, new_state=<state automation.shellies_discovery=on; last_triggered=2020-06-27T11:27:36.671584+03:00, id=shellies_discovery, friendly_name=Shellies Discovery @ 2020-06-26T19:10:02.512492+03:00>>},
2020-06-27 11:27:36 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.shellies_discovery, old_state=<state automation.shellies_discovery=on; last_triggered=2020-06-26T19:21:41.667966+03:00, id=shellies_discovery, friendly_name=Shellies Discovery @ 2020-06-26T19:10:02.512492+03:00>, new_state=<state automation.shellies_discovery=on; last_triggered=2020-06-27T11:27:36.671584+03:00, id=shellies_discovery, friendly_name=Shellies Discovery @ 2020-06-26T19:10:02.512492+03:00>>,
2020-06-27 11:27:36 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.shellies_announce, old_state=<state automation.shellies_announce=on; last_triggered=2020-06-26T19:21:41.609476+03:00, id=shellies_announce, friendly_name=Shellies Announce @ 2020-06-26T19:10:02.511903+03:00>, new_state=<state automation.shellies_announce=on; last_triggered=2020-06-27T11:27:36.545196+03:00, id=shellies_announce, friendly_name=Shellies Announce @ 2020-06-26T19:10:02.511903+03:00>>,
2020-06-27 11:27:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.2916994608] Sending {'id': 2, 'type': 'event', 'event': <Event state_changed[L]: entity_id=automation.shellies_announce, old_state=<state automation.shellies_announce=on; last_triggered=2020-06-26T19:21:41.609476+03:00, id=shellies_announce, friendly_name=Shellies Announce @ 2020-06-26T19:10:02.511903+03:00>, new_state=<state automation.shellies_announce=on; last_triggered=2020-06-27T11:27:36.545196+03:00, id=shellies_announce, friendly_name=Shellies Announce @ 2020-06-26T19:10:02.511903+03:00>>},
2020-06-27 11:27:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.2916923888] Sending {'id': 2, 'type': 'event', 'event': <Event state_changed[L]: entity_id=automation.shellies_announce, old_state=<state automation.shellies_announce=on; last_triggered=2020-06-26T19:21:41.609476+03:00, id=shellies_announce, friendly_name=Shellies Announce @ 2020-06-26T19:10:02.511903+03:00>, new_state=<state automation.shellies_announce=on; last_triggered=2020-06-27T11:27:36.545196+03:00, id=shellies_announce, friendly_name=Shellies Announce @ 2020-06-26T19:10:02.511903+03:00>>},2020-06-27 11:27:36 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.shellies_discovery, old_state=<state automation.shellies_discovery=on; last_triggered=2020-06-26T19:21:41.667966+03:00, id=shellies_discovery, friendly_name=Shellies Discovery @ 2020-06-26T19:10:02.512492+03:00>, new_state=<state automation.shellies_discovery=on; last_triggered=2020-06-27T11:27:36.671584+03:00, id=shellies_discovery, friendly_name=Shellies Discovery @ 2020-06-26T19:10:02.512492+03:00>>,
2020-06-27 11:27:36 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on shellies/announce: b'{"id":"shellydimmer2-E0980695AF0D","mac":"E0980695AF0D","ip":"192.168.1.128","new_fw":false, "fw_ver":"20200528-111028/1026-new-device-dimmer-l@98d7122e"}',
2020-06-27 11:27:36 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event automation_triggered[L]: name=Shellies Announce, entity_id=automation.shellies_announce>,
2020-06-27 11:27:36 INFO (MainThread) [homeassistant.components.automation] Executing Shellies Announce,
2020-06-27 11:27:36 INFO (MainThread) [homeassistant.components.automation] Shellies Announce: Running script,
2020-06-27 11:27:36 INFO (MainThread) [homeassistant.components.automation] Shellies Announce: Executing step call service,
2020-06-27 11:27:36 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=mqtt, service=publish, service_data=topic=shellies/command, payload=announce>,
2020-06-27 11:27:36 DEBUG (MainThread) [homeassistant.components.mqtt] Transmitting message on shellies/command: announce,
2020-06-27 11:27:36 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=automation, service=trigger, service_data=entity_id=automation.shellies_announce>,
2020-06-27 11:27:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.2916994608] Received {'type': 'call_service', 'domain': 'automation', 'service': 'trigger', 'service_data': {'entity_id': 'automation.shellies_announce'}, 'id': 3684}
Thatâs my debug, I donât see problems, shelly was discovered, but no integration or entity created. Could you help me?
debug
for python_script
is needed. This doesnât tell me anything.
I have 5 shelly dimmers, and in the âShellies Discoveryâ automation, all of them setup similarly, like
shellydimmer-XXXXXX:
light-0-name: "Living Room Spot Lights"
force_update_sensors: true
For 4 of the dimmers the friendly name in HA uses the light-0-name value specified for each dimmer, but the 5fifth keeps using âShelly Dimmer XXXXXX Light 0â as friendly name. Anyone seen this behavior before?
This configuration is wrong. relay-0-name
not light-0-name
.
Also for dimmers? And any idea why itâs working for the other 4?
Have tried with relay-0-name and same result
Without a log and configuration I have no idea why is that.
I wrote these lines to configuration, where should I check for python log???
EDIT: seems everything working, itâs just need to implement shellydimmer2, because I have new type of dimmer. Please could you update the code? Do you need any info?
I need deviceâs topics/payloads.
This is in my config. I have triple checked the IDâs of each device. For all devices, the friendly names are changed as per config except for the âLiving Room Led Stripsâ.
- id: 263db818-00d1-4691-8847-b0bd2d491fbb
alias: 'Shellies Announce'
trigger:
- platform: homeassistant
event: start
action:
service: mqtt.publish
data:
topic: shellies/command
payload: announce
- id: 9d090e06-286a-437d-9e76-810f938782f0
alias: 'Shellies Discovery'
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 }}'
discovery_prefix: 'homeassistant'
qos: 0
shellyplug-s-XXXXXX:
relay-0: "switch"
relay-0-name: "Living Room Amplifier"
force_update_sensors: true
shellyplug-s-XXXXXX:
relay-0: "light"
relay-0-name: "Backyard Garden Lights"
force_update_sensors: true
shellyplug-s-XXXXXX:
relay-0: "switch"
relay-0-name: "Attic Washing Machine"
force_update_sensors: true
shellyplug-s-XXXXXX:
relay-0: "switch"
relay-0-name: "Attic Tumble Dryer"
force_update_sensors: true
shellyswitch25-XXXXXX:
mode: "roller"
roller-0-name: "Master Bedroom Roller Shutter"
force_update_sensors: true
shellyswitch25-XXXXXX:
mode: "roller"
roller-0-name: "Lucas Room Roller Shutter"
force_update_sensors: true
shellyswitch25-XXXXXX:
mode: "roller"
roller-0-name: "Backyard Awning"
force_update_sensors: true
shellydimmer-XXXXXX:
relay-0-name: "Living Room Dining Table Light"
force_update_sensors: true
shellydimmer-XXXXXX:
relay-0-name: "Living Room Wall Lights"
force_update_sensors: true
shellydimmer-XXXXXX:
relay-0-name: "Living Room Spot Lights"
force_update_sensors: true
shellydimmer-XXXXXX:
relay-0-name: "Living Room Led Strips"
force_update_sensors: true
shellydimmer-XXXXXX:
relay-0-name: "Office Spots"
force_update_sensors: true
shelly1pm-XXXXXX:
relay-0: "light"
relay-0-name: "Hallway Light"
push_off_delay: false
force_update_sensors: true
shelly1pm-XXXXXX:
relay-0: "light"
relay-0-name: "Attic Light"
push_off_delay: false
force_update_sensors: true
shelly1pm-XXXXXX:
relay-0: "light"
relay-0-name: "Backyard Wall Lights"
push_off_delay: false
force_update_sensors: true
When I trigger the automation manually, when I listen to topic âshellies/anounceâ I see this message passing (along with messages on the other devices)
In my log I see this
Any idea what this might be?
But⌠name
is only supported by relays and rollers.
Awesome, thanks!
Not working completely as expected. This is what I see in the log:
Logger: homeassistant.components.python_script.shellies_discovery.py
Source: components/python_script/__init__.py:205
Integration: Python Scripts (documentation, issues)
First occurred: June 29, 2020, 11:52:48 PM (5 occurrences)
Last logged: June 29, 2020, 11:52:48 PM
Error executing script: name 'light_name' is not defined
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 205, in execute
exec(compiled.code, restricted_globals)
File "shellies_discovery.py", line 1500, in <module>
NameError: name 'light_name' is not defined
Looked into the python script, but couldnât find anything obvious myself
New question
For shelly1 PM, Shelly 2.5 and Shelly Dimmers, I notice that when specifying resp. relay-0-name, roller-0-name and light-0-name in HA not only the friendly name is changed, but also the entity id.
Is there is a reason why for the Shelly Plug S only the friendly name is changed and not the entity id?
I have these devices in my Shellies Discovery automation (notice one is a light, and the other a switch):
shellyplug-s-XXXXXX:
relay-0: "switch"
relay-0-name: "Living Room Amplifier"
force_update_sensors: true
shellyplug-s-XXXXXX:
relay-0: "light"
relay-0-name: "Backyard Garden Lights"
force_update_sensors: true
The script doesnât change the name of the entity or entity_id
, only passes the name to HA. It is HA that manages names and entity_ids
. You have probably previously changed this entity_id
manually, and HA respects your change.