With the current Shelly firmware version, it is not possible to properly configure the color bulb via MQTT.
I feel I’m maybe missing something really obvious. I’ve installed the script and it does run but does not detect my shellies. They are being detected by the mqtt broker. I’ve taken the minimal configuration yam. and not changed it, am I meant to change this?
No, the minimal configuration should be enough.
Ok I’ve identified the problem, I’ve a mix of gen 1 and gen 2 devices, when the gen 2 script finds my Shelly em it just fails and does not proceed. Is there a recommended way to have both scripts working?
2022-12-28 00:00:00.336 ERROR (SyncWorker_2) [homeassistant.components.python_script.shellies_discovery.py] Error executing script: model shellyem is not supported, please open an issue here https://github.com/bieniu/ha-shellies-discovery-gen2/issues
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 224, in execute
exec(compiled.code, restricted_globals)
File "shellies_discovery.py", line 1620, in <module>
ValueError: model shellyem is not supported, please open an issue here https://github.com/bieniu/ha-shellies-discovery-gen2/issues
2022-12-28 00:00:10.132 INFO (Recorder) [homeassistant.components.sensor.recorder]
Gen 1 and Gen 2 scripts can run side by side at the same time. Shelly EM is a first generation device.
Based on the error message, the gen 2 script fails once a Shelly em is detected and doesn’t discover my shell 1 pm plus gen 2 devices. Is this expected?
You’ve installed gen2 script with gen1 script file name, the chaos is expected
I’ve got 4 Shelly 1PMs and 2 H&Ts. I’m using HA 2022.12 and the latest version of the script. However in MQTT devices I can only see the 1PMs and not the H&Ts.
Pressing the button on the H&T seems to announce correctly so the messages do seem to be getting from the H&T to the broker OK. I also get them if I manually subscribe to that topic in HA, but would be good to have the devices show up so I can display them in Lovelace, etc.
OK, thanks - I have done. I’ve attached the main HA log, I wasn’t sure if there was a different one for python_script? (I’ve set homeassistant.components.python_script
to debug in logger but couldn’t see if there was a separate file?)
Just thought I’d chime in and thank Dev for this great script.
Was having trouble getting the core Shelly Integration to work with my Shelly Button and after switching over to this script everything works flawless with even more entities showing up in the mqtt
Hello! I need some help… can’t get the script to discover my Shelly PlugS.
This is the announce, as seen from MQTT Explorer:
{
"id": "shellyplug-s-881A4C",
"mac": "7C87CE881A4C",
"ip": "10.0.0.199",
"new_fw": false,
"fw_ver": "20190516-073020/master@ea1b23db"
}
This is my automations.yaml, the relevant part:
- 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
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 | default }}'
mode: '{{ trigger.payload_json.mode | default }}'
host: '{{ trigger.payload_json.ip }}'
that’s basically a copy-paste from the minimal configuration in the README, I didn’t change anything.
This is the error in the logs:
2023-01-23 12:00:00.392 INFO (MainThread) [homeassistant.components.automation.shellies_announce] Shellies Announce: Running automation actions
2023-01-23 12:00:00.393 INFO (MainThread) [homeassistant.components.automation.shellies_announce] Shellies Announce: Executing step call service
2023-01-23 12:00:00.427 INFO (MainThread) [homeassistant.components.automation.shellies_discovery_2] Shellies Discovery: Running automation actions
2023-01-23 12:00:00.427 INFO (MainThread) [homeassistant.components.automation.shellies_discovery_2] Shellies Discovery: Executing step call service
2023-01-23 12:00:00.496 INFO (SyncWorker_5) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellyplug-s-881A4C', 'mac': '7C87CE881A4C', 'fw_ver': '20190516-0730>
2023-01-23 12:00:00.496 ERROR (SyncWorker_5) [homeassistant.components.python_script.shellies_discovery.py] Error executing script: model_id value None is not valid, check script configuration
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 224, in execute
exec(compiled.code, restricted_globals)
File "shellies_discovery.py", line 1578, in <module>
ValueError: model_id value None is not valid, check script configuration
I am assuming that Shelly PlugS is not a generation 2 device, is that correct?
I found some posts in the current thread with that error, but they were all RGBW2 issues, not PlugS, and the solutions proposed there didn’t help. Any further ideas to troubleshoot? Thanks!
You have to update the firmware, it’s too old and not supported by the script.
It says there is no newer version available…
I didn’t adopt it on the Shelly app, I wonder if that has anything to do with this?
EDIT: ok, I got this sorted out. Got a new firmware from http://archive.shelly-tools.de/ , updated, and now my Shelly is discovered
Thanks for the help, and for the software!
Hi Bieniu,
many thanks for this great script! I cant get it working properly though. What I did for installation was:
-I added “python_script” to configuration.yaml
-I copied the shellies-discovery.py to the phyton_scripts folder
-I added the described minimal configuration to automations.yaml
The status is that:
-In the “core-mosquitto” integration the Shelly Button1 device shows up
-I can see 7 different diagnostic entities (battery, charger, firmware, IP, last restart. SSID. wifi signal) which are working fine… I can see e.g. the battery has 100% capacity right now
-The problem is that all “control” entities are completely missing! I saw in another youtube video that there should be the entities Shortpush, Longpush, Double & Triple Shortpush, Longpush
I dont know if that is related (since discovery seems to at least partially work) but when I restart HA I receive the following error message concerning the discover automation:
Shellies Discovery uses an unknown service
The automation “Shellies Discovery” (automation.shellies_discovery
) has an action that calls an unknown service: python_script.shellies_discovery
.
When I click on the automation step details I receive the following error:
Error: Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘payload_json’
I am using the following HA versions:
Home Assistant 2023.3.0
Supervisor 2023.01.1
Operating System 9.5
Frontend 20230301.0 - latest
I cannot assign any automation to the Shelly Button if e.g. the shortpush entity is missing! Please help!
Many thanks in advance
Martin
For monostable buttons, no entities are created, only device automation triggers. Look here GitHub - bieniu/ha-shellies-discovery: Script that adds MQTT discovery support for Shellies devices
This means that the script is not installed correctly.
many thanks! I reinstalled and now the error message vanished.
Also the GIF you linked to was a great help - I could solve it with that and the switches now work!!
Bieniu,
I can confirm after some more testing that my automation works fine now, so my proiblem is solved!
What I would highly appreciate still if you could confirm my setup all right, or if I need to reinstall again. The two things I noticed which seem very strange are:
- When I click on the Shelly Button device I can only see the sensors and diagnostic. In your GIF I also see the button actions such as “longpush” with the state (OFF). I have attached 2 screenshots from my and your setup to make clear what I mean
- In the screenshot of my setup you will see in the diagnostic section “last restart - 2 hours ago”. Also in the logbook on the right hand side several restart dates and times. What I found out was that this is actually not the restart but each time I push the Shelly Button even though the automation is working fine it is recognized as a “restart” from the diagnosis (entity ID in Logbook is shown as “sensor.shelly_button1_485519ca25dd_last_restart”. In the following I will paste the YAML of my automation, which is working fine nonetheless.
So do you think my setup is messed up somehow or can I relayx and just continue with that?
Br
Martin
alias: mqtt G15 open
description: “”
trigger:
- platform: device
domain: mqtt
device_id: 39a99d7309bee1b89431f3add8e9d641
type: button_short_press
subtype: button_1
discovery_id: shellybutton1-485519CA25DD-input-0 button_short_press
condition: []
action: - device_id: 07f48852e3588ac65ab714e0422cbb0e
domain: lock
entity_id: lock.nuki_tur_g15_lock
type: open
mode: single
shortpush
and longpush
entities were removed long time ago.
Shelly Button1 is a sleeping device, when you press the button it will wake up and connect to the MQTT broker, also uptime/last restart will be reset at this point.
Everything looks normal. Input 0
sensor is unavailable, I’m not sure if it should be created for Button1. I’ll check that.
phew, many many thanks for the very quick and complete answers!!!
I just donated some coffee via paypal
pls keep up the good work!
All the best
Martin