Shellies Discovery Script

New version: 0.12.0

Changelog:

  • add suport for Shelly Bulb (experimental)
  • fix effect list for Shelly RGBW2

Is this script still on HACS? I don’t see it, only Shelly related thing appearing is the custom component.

@Bieniu i just got one of the rgbw2 controllers that I am getting an error with. I have the script installed from HACS and working fine with your minimal configuration example and the controller is on latest firmware. The light shows up and is controllable and one binary sensor is created called " Shelly RGBW2 66243C Overpower 0 " with a value of unavailable and I am getting the error

No matching payload found for entity: Shelly RGBW2 66243C Overpower 0 with state_topic: shellies/shellyrgbw2-66243C/color/0/status

that has shown up over a hundred times in the last hour. Any ideas on what i need to do to fix this?

According to this https://shelly-api-docs.shelly.cloud/#rgbw2-mqtt script uses correct topic. Can you check what is the payload for shellies/shellyrgbw2-66243C/color/0/status topic?

Looks like i have an exra line “mode”

{
    "ison": false,
    "mode": "color",
    "red": 255,
    "green": 255,
    "blue": 255,
    "white": 75,
    "gain": 4,
    "effect": 0,
    "power": 0,
    "overpower": false
}

Looks good.
Could you try add manually to your configuration this sensor for try:

binary_sensor:
  - platform: mqtt
    name: "Overpower Test"
    state_topic: "shellies/shellyrgbw2-66243C/color/0/status"
    value_template: "{{ value_json.overpower }}"
    payload_on: "true"
    payload_off: "false"
    availability_topic: "shellies/shellyrgbw2-66243C/online"
    payload_available: "true"
    payload_not_available: "false"

You can also check that there is a config topic for this sensor on your MQTT broker. You can use MQTT Explorer for that.
This topic should looks like this:

homeassistant/binary_sensor/shellyrgbw2-66243C-overpower-0/config
{
	"name": "Shelly RGBW2 66243C Overpower 0",
	"stat_t": "~color/0/status",
	"val_tpl": "{{ value_json.overpower }}",
	"pl_on": "true",
	"pl_off": "false",
	"avty_t": "~online",
	"pl_avail": "true",
	"pl_not_avail": "false",
	"uniq_id": "shellyrgbw2-66243C-color-overpower-0",
	"qos": "0",
	"dev": {
		"ids": ["XXXXXXXX"],
		"name": "Shelly RGBW2 66243C",
		"mdl": "Shelly RGBW2",
		"sw": "20190402-134544/v1.5.1@9be72c7e",
		"mf": "Allterco Robotics"
	},
	"~": "shellies/shellyrgbw2-66243C/"
}

I think I found the issue. Could you try this version of the script?

Ok so using the version you posted, the binary sensor now works and reports as off. However i am still getting the same error message every couple minutes. here is the topic from mqtt:

homeassistant/binary_sensor/shellyrgbw2-66243C-color-overpower-0/config


"name":"Shelly RGBW2 66243C Overpower 0",
"stat_t":"~color/0/status",
"val_tpl":"{{ value_json.overpower }}",
"pl_on":"true",
"pl_off":"false",
"avty_t":"~online",
"pl_avail":"true",
"pl_not_avail":"false",
"uniq_id":"shellyrgbw2-66243C-color-overpower-0",
"qos":"0",
"dev": {
"ids": ["xxxxxxxxxxxx"],
"name":"Shelly RGBW2 66243C",
"mdl":"Shelly RGBW2",
"sw":"20190821-095258/v1.5.2@4148d2b7",
"mf":"Allterco Robotics"
},
"~":"shellies/shellyrgbw2-66243C/"

Try this version of the script https://github.com/bieniu/ha-shellies-discovery/blob/009d36daa590f163a93065ce98a852449c27bb99/python_scripts/shellies_discovery.py

Im sorry if i wasnt clear, or i may be missing something but i already tried https://github.com/bieniu/ha-shellies-discovery/blob/009d36daa590f163a93065ce98a852449c27bb99/python_scripts/shellies_discovery.py with the results above

Sorry, I read your answer too fast :wink:
Try this new version https://github.com/bieniu/ha-shellies-discovery/blob/ff6a1d8737c959fdfcd4984da716555978fbb272/python_scripts/shellies_discovery.py

That was it! no more errors in the logs and binary sensor is reporting status. Thank you so much for spending some time on this. I’ve really started liking these shellies devices and your script makes the integration so easy. thanks again.

Ha super.
Merci pour ce travail.
Thanks !!!

1 Like

New version: 0.12.3

Changelog:

  • fix Shelly RGBW2 warnings for overpower sensor

I can’t get mqtt discovery active for my new shelly1. I am a new hassio (latest version) user, have sonos and zigbee devices active but shelly does not work. What am I doing wrong? MQTT Mosquitto log gives no error messages and shelly’s automations seem to be active, but in integration no shelly device appears
Spend a few hours reading posts in this forum but still no succes.
what to do now?

I don’t know. Show me your MQTT broker, script and Shelly configuration.

Thanks for your help Maciek, hope this info will help

log form MQTT

Log
[16:25:01] INFO: Setup mosquitto configuration
[16:25:01] WARNING: SSL not enabled - No valid certs found!
[16:25:01] INFO: No local user available
[16:25:01] INFO: Initialize Hass.io Add-on services
[16:25:02] INFO: Initialize Home Assistant discovery
[16:25:02] INFO: Start Mosquitto daemon
1570717502: mosquitto version 1.6.3 starting
1570717502: Config loaded from /etc/mosquitto.conf.
1570717502: Loading plugin: /usr/share/mosquitto/auth-plug.so
1570717502: |-- *** auth-plug: startup
1570717502: ├── Username/password checking enabled.
1570717502: ├── TLS-PSK checking enabled.
1570717502: └── Extended authentication not enabled.
1570717502: Opening ipv4 listen socket on port 1883.
1570717502: Opening ipv6 listen socket on port 1883.
1570717502: Opening websockets listen socket on port 1884.
1570717502: Warning: Mosquitto should not be run as root/administrator.
1570717556: New connection from 172.30.32.1 on port 1883.
[INFO] found homeassistant on local database
1570717556: New client connected from 172.30.32.1 as auto-077A18D0-B00C-3583-4B3B-A3122E477AD9 (p2, c1, k60, u’homeassistant’).
1570719333: Saving in-memory database to /data/mosquitto.db.
1570719556: Client auto-077A18D0-B00C-3583-4B3B-A3122E477AD9 disconnected.
1570719575: New connection from 172.30.32.1 on port 1883.
[INFO] found homeassistant on local database
1570719575: New client connected from 172.30.32.1 as auto-95D77C08-7F1D-FB1F-34BA-04996D298800 (p2, c1, k60, u’homeassistant’).

############################
from /config/automations.yaml (identical to your spec’s)

  • id: shellies_announce
    alias: ‘Shellies Announce’
    trigger:

    • platform: homeassistant
      event: start
      action:
      service: mqtt.publish
      data:
      topic: shellies/command
      payload: announce
  • id: ‘shellies_discovery’
    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 }}’

####################################
from /config/configuration.yaml

python_script:

####################################
in /config/python_scripts a copie off shellies_discovery.py

Is Shelly’s topic configuration default? What is your discovery_prefix in MQTT broker configuration?

from MQTT Mosquitto broker addon

{
“logins”: [],
“anonymous”: true,
“customize”: {
“active”: false,
“folder”: “mosquitto”
},
“certfile”: “fullchain.pem”,
“keyfile”: “privkey.pem”,
“require_certificate”: false
}