ShellyTeacher for Domoticz

For devices supporting the Auto Discovery feature. Like ZWaveJS2MQTT, Zigbee2MQTT.

Moderator: leecollings

lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: ShellyTeacher for Domoticz

Post by lwolf »

Quax1507 wrote: Saturday 03 February 2024 10:51 I still have the issue that teached devices do no longer work after restart of Domoticz. See https://www.domoticz.com/forum/viewtopi ... 06#p312206

Error in Domoticz:

Code: Select all

Error: Shelly MQTT: Switch not found!? (shellyplus2pm-d48afc4447d4-roller-pos-c/Küche Rollo)
But the device is in the Domoticz devices:

03-02-2024_10-49-51.jpg
Yes, its in the Domoticz database. But i guess the necessary configuration object is not found under the Autodiscovery topic, and Domoticz has no idea how to manage that device if configuration object is missing.
Quax1507 wrote: Saturday 03 February 2024 10:51 I am using mosquitto and the retain flag is set. How can I troubleshoot? Can I check the retain somwhere in MQTTexplorer?
Reboot the whole device with MQTT broker. If the homeassistent/shellyplus2pm-xxxx-roler-pos-c/config topic does not exists or does not contain data, your MQTT persistence is simply not working. If you see the config template in there and a RETAINED text appears above the value in yellow (or red) background, than it is retained. In your device's RAM.
Image

Troubleshoot... Linux basic knowledge required for that. For example if i logon my box and issue this command:

Code: Select all

sudo cat /var/log/mosquitto/mosquitto.log
Than it informs me that the database is saved to the disk from the memory, so the persistance settings is working if i see something like this:

Code: Select all

Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
Quax1507 wrote: Saturday 03 February 2024 10:51 Any indea? Do You recommend another MQTT broker?
I am using mosquitto also without issues. I configured it to save persistence file to disk and it simply works:
https://pagefault.blog/2020/02/05/how-t ... tt-broker/
Quax1507 wrote: Saturday 03 February 2024 10:51 EDIT: there are no devices when I go to Setup -> Hardware -> MQTT Auto Discovery Client Gateway with LAN interface -> Setup
Is this OK??
There is nothing to see there. It holds variables for MQTT devices which supports them. I do not know any device that supports it. Maybe some zigbee2mqtt device does...
Quax1507 wrote: Saturday 03 February 2024 10:51 shellyplus2pm-d48afc4447d4-roller-pos-c/Küche Rollo
PS: you do not send your complete topic name, i hope "Küche" is not included there.
Based on the official HA docs, device topic and name must only consist of characters from the character class [a-zA-Z0-9_-] (alphanumerics, underscore and hyphen). https://www.home-assistant.io/integrations/mqtt/
Quax1507
Posts: 101
Joined: Tuesday 07 April 2015 21:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: ShellyTeacher for Domoticz

Post by Quax1507 »

Thank You very much for Your comments.
I checked all of Your mentioned topics and it all was okay.
I enden up in deleting the Mosquitto DB and let Mosquitto re-create it.
At the moment everything looks good! :D
lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: ShellyTeacher for Domoticz

Post by lwolf »

Quax1507 wrote: Sunday 04 February 2024 10:33 Thank You very much for Your comments.
I checked all of Your mentioned topics and it all was okay.
I enden up in deleting the Mosquitto DB and let Mosquitto re-create it.
At the moment everything looks good! :D
I'm glad it works.
Very interesting case, maybe a database error occured in the mosquitto.db file. Earlier I saw strange errors with malfunctioning SD card without any error message, which are gone when i swapped the SD card.
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: ShellyTeacher for Domoticz

Post by Derik »

Perhaps some one use a nodered script for using shellys?
I run a script perhaps not perfect only it runs:-)
Like to use devices witouth plugins etc.
i do have switches working, no shutter and other devices.

Interrest?
Or others that runs a nr script i like to see
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: ShellyTeacher for Domoticz

Post by waltervl »

If you do not want to use plugins you need this ShellyTeacher script.......
You have to run it only once after every new Shelly or Shellies you add. Then standard MQTT Auto discover is used for discovering, creating Domoticz devices and updating statuses

For node red you need to do much more. And it is strange to ask for node red flows in this topic. Sure there are but here is a node red subforum on this forum.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Thermojito
Posts: 12
Joined: Monday 05 March 2018 22:52
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: ShellyTeacher for Domoticz

Post by Thermojito »

ShellyTeacher has been working great so far but now I'm facing an issue where I'm a bit stuck troubleshooting due to lack of knowledge of how "MQTT Autodiscovery" and ShellyTeacher works internally:

I added a ShellyPlus1 that worked all the way to and from Domoticz, BUT when I added a Shelly "Sensor Add-on" on top of this Shelly I don't get all of the sensors to appear in Domoticz.

When I'm checking with: http://192.168.1.xx/rpc/SensorAddon.GetPeripherals I get the following response on configured links to the activated sensors: (Dig_In, 5 temp-sensors and the Analog_In)

Code: Select all

{
    "digital_in": {
        "input:100": {}
    },
    "ds18b20": {
        "temperature:100": {
            "addr": "40:255:100:29:241:154:188:112"
        },
        "temperature:101": {
            "addr": "40:255:100:29:248:110:5:242"
        },
        "temperature:102": {
            "addr": "40:255:100:29:249:149:135:211"
        },
        "temperature:103": {
            "addr": "40:255:100:29:249:205:54:190"
        },
        "temperature:104": {
            "addr": "40:70:26:195:94:20:1:175"
        }
    },
    "dht22": {},
    "analog_in": {},
    "voltmeter": {
        "voltmeter:100": {}
    }
}
I can also see all these sensors using MQTT Explorer under the "device-topic":

Code: Select all

shellyplus1-08b61fd95d44
online = true
events
rpc = {"src":"shellyplus1-08b61fd95d44","dst":"shellyplus1-08b61fd95d44/events","method":"NotifyStatus","params":{"ts":267820.50,"temperature:104":{"id":104,"tC":20.48,"tF":68.86}}}
status
temperature:100 = {"id": 100,"tC":20.7, "tF":69.3}
temperature:104 = {"id": 104,"tC":20.5, "tF":68.9}
temperature:101 = {"id": 101,"tC":20.5, "tF":68.9}
input:100 = {"id":100,"state":false}
voltmeter:100 = {"id": 100,"voltage":9.60}
switch:0 = {"id":0, "source":"button", "output":true,"temperature":{"tC":53.7, "tF":128.6}}
temperature:102 = {"id": 102,"tC":20.5, "tF":68.8}
temperature:103 = {"id": 103,"tC":20.9, "tF":69.6}
rpc = {"id": 1, "src":"shellies_discovery", "method":"Shelly.GetConfig"}
And after running ShellyTeacher the input and outputs are added to the Discovery-topic and as Domoticz-devices, except:
  • temperature:103
  • temperature:104
  • voltmeter:100
  • and the digital input
I've tried to remove everything related to this Shellyplus1 in MQTT under both the device-topic and Discovery-topic and then removing all related devices from Domoticz and then run the ShellyTeacher again and rebooting Domoticz, still without success.

Any ideas what I can do to add the remaining sensors all the way to/from Domoticz?
Thermojito
Posts: 12
Joined: Monday 05 March 2018 22:52
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: ShellyTeacher for Domoticz

Post by Thermojito »

I can add for other users with problems using the Shelly Sensor Add-on that the Firmware in the "base-Shelly" might need to be updated, in my case I updated to the latest Firmware 20240223-141953/1.2.2-g7c39781 to get the menu's needed to manually activate all the sensor inputs. Without this manual activation none of the sensors will appear in MQTT and obviously not in Domoticz either.
Thermojito
Posts: 12
Joined: Monday 05 March 2018 22:52
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: ShellyTeacher for Domoticz

Post by Thermojito »

I guess the MQTT Autodiscovery topic entries might also be a clue to why Domoticz are not picking up all the sensors, adding the parts related to this device here:

Code: Select all

switch
shellyplus1-08b61fd95d44-0
config = {"name": "shellyplus1-08b61fd95d44 Relay 0", "cmd_t": "~rpc", "pl_off": "{\"id\":1,\"src\":\"shellyplus1-08b61fd95d44\",\"method\":\"Switch.Set\",\"params\":{\"id\":0,\"on\":false}}", "pl_on": "{\"id\":1,\"src\":\"shellyplus1-08b61fd95d44\",\"method\":\"Switch.Set\",\"params\":{\"id\":0,\"on\":true}}", "stat_t": "~status/switch:0", "val_tpl": "{{ value_json.output }}","stat_off": "false","stat_on"…
sensor
shellyplus1-08b61fd95d44-0
temperature
config = {"name": "shellyplus1-08b61fd95d44 Temperature", "enabled_by_default": true, "uniq_id": "shellyplus1-08b61fd95d44-temperature", "qos": 0, "~":"shellyplus1-08b61fd95d44/", "entity_category": "diagnostic", "dev_cla": "temperature", "stat_cla": "measurement", "unit_of_meas": "C","stat_t": "~status/switch:0", "val_tpl": "{{ value_json['temperature'].tC }}", "avty_t": "~online", "pl_avail": "true", "pl…
shellyplus1-08b61fd95d44-ext-0
temperature
config = {"name": "shellyplus1-08b61fd95d44 Temperature Ext0", "enabled_by_default": false, "uniq_id": "shellyplus1-08b61fd95d44-temperature-100", "qos": 0, "~":"shellyplus1-08b61fd95d44/", "dev_cla": "temperature", "stat_cla": "measurement", "unit_of_meas": "C","stat_t": "~status/temperature:100", "val_tpl": "{{ value_json.tC }}", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false","device": …
humidity
shellyplus1-08b61fd95d44-ext-0-s
temperature
config = {"name": "shellyplus1-08b61fd95d44 Temperature Ext0 S", "enabled_by_default": false, "uniq_id": "shellyplus1-08b61fd95d44-temperature-100-s", "qos": 0, "~":"shellyplus1-08b61fd95d44/", "dev_cla": "temperature", "stat_cla": "measurement", "unit_of_meas": "C","stat_t": "~status/temperature:100", "val_tpl": "{{ value_json.tC }}", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false"}
shellyplus1-08b61fd95d44-ext-1
temperature
config = {"name": "shellyplus1-08b61fd95d44 Temperature Ext1", "enabled_by_default": false, "uniq_id": "shellyplus1-08b61fd95d44-temperature-101", "qos": 0, "~":"shellyplus1-08b61fd95d44/", "dev_cla": "temperature", "stat_cla": "measurement", "unit_of_meas": "C","stat_t": "~status/temperature:101", "val_tpl": "{{ value_json.tC }}", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false"}
shellyplus1-08b61fd95d44-ext-2
temperature
config = {"name": "shellyplus1-08b61fd95d44 Temperature Ext2", "enabled_by_default": false, "uniq_id": "shellyplus1-08b61fd95d44-temperature-102", "qos": 0, "~":"shellyplus1-08b61fd95d44/", "dev_cla": "temperature", "stat_cla": "measurement", "unit_of_meas": "C","stat_t": "~status/temperature:102", "val_tpl": "{{ value_json.tC }}", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false"}
shellyplus1-08b61fd95d44-ext
voltage
config = {"name": "shellyplus1-08b61fd95d44 Addon Voltmeter 0", "~": "shellyplus1-08b61fd95d44/", "stat_t": "~status/voltmeter:100", "enabled_by_default": false, "uniq_id": "shellyplus1-08b61fd95d44-ext-voltmeter", "qos": 0, "dev_cla": "voltage", "stat_cla": "measurement", "unit_of_meas": "V", "val_tpl": "{{ value_json.voltage }}"}
binary_sensor
shellyplus1-08b61fd95d44-0
input
config = {"name": "shellyplus1-08b61fd95d44 Input 0", "val_tpl": "{{ value_json.state }}","stat_off": "false","stat_on": "true","enabled_by_default": true, "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false", "uniq_id": "shellyplus1-08b61fd95d44-0-input", "qos": 0, "device": {"identifiers": ["08B61FD95D44"],"manufacturer": "Shelly","model": "shellyplus1","name": "shellyplus1-08b61fd95d44"}, "~…
shellyplus1-08b61fd95d44-online
config = {"name": "shellyplus1-08b61fd95d44 Online", "stat_t": "~online", "uniq_id": "shellyplus1-08b61fd95d44-online", "~": "shellyplus1-08b61fd95d44/", "pl_on": "true", "pl_off": "false"}
select
shellyplus1-08b61fd95d44
input_event-0
config = {"name": "shellyplus1-08b61fd95d44 Input Event 0", "json_attributes_topic": "~events/rpc", "value_template":"{{value_json['params']['events'][0].event}}", "cmd_t": "~dummy", "frc_upd": true, "enabled_by_default": false, "uniq_id": "shellyplus1-08b61fd95d44-event-0", "~":"shellyplus1-08b61fd95d44/", "dev_cla": "event", "stat_cla": "selector" , "ops":["-","scheduled_restart","btn_down","btn_up","sin…
At least there are 5 temperature sensors and 1 digital input mentioned....but I cannot find anything related to a voltmeter/analog_in and the CPU-temperature would probably count as one temp-sensor and I have no combined humidity/temp sensor connected which removes another temp-sensor candidate...and the normal binary 230VAC switch input on the base-shelly works fine in Domoticz, hence I cannot see anything related to the low voltage digital input either...?

But as said in the beginning, I don't know much of the inner details of MQTT Autodiscovery but I'm trying to learn!
Thermojito
Posts: 12
Joined: Monday 05 March 2018 22:52
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: ShellyTeacher for Domoticz

Post by Thermojito »

Issue solved!!!!

By adding these six lines in the mqtt_templates_gen2.txt as the last part of the section valid for the used base Shelly ("ShellyPlus1" in my case) I can finally see all devices from the Shelly AddOn in Domoticz!

Code: Select all

topic=%discovery_prefix%/sensor/%shelly_id%-ext-3/temperature/config
payload={"name": "%shelly_id% Temperature Ext3", "enabled_by_default": false, "uniq_id": "%shelly_id%-temperature-103", "qos": 0, "~":"%shelly_topic%/", "dev_cla": "temperature", "stat_cla": "measurement", "unit_of_meas": "C","stat_t": "~status/temperature:103", "val_tpl": "{{ value_json.tC }}", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false"}
topic=%discovery_prefix%/sensor/%shelly_id%-ext-4/temperature/config
payload={"name": "%shelly_id% Temperature Ext4", "enabled_by_default": false, "uniq_id": "%shelly_id%-temperature-104", "qos": 0, "~":"%shelly_topic%/", "dev_cla": "temperature", "stat_cla": "measurement", "unit_of_meas": "C","stat_t": "~status/temperature:104", "val_tpl": "{{ value_json.tC }}", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false"}
topic=%discovery_prefix%/binary_sensor/%shelly_id%-1/input/config
payload={"name": "%shelly_topic% Input Ext", "val_tpl": "{{ value_json.state }}","stat_off": "false","stat_on": "true","enabled_by_default": false, "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false", "uniq_id": "%shelly_id%-ext-input", "qos": 0, "device": {"identifiers": ["%shelly_mac%"],"manufacturer": "Shelly","model": "%shelly_model%","name": "%shelly_id%"}, "~": "%shelly_topic%/", "stat_t": "~status/input:100"}
While having the ShellyTeacher running I forced all inputs to change their values at least once after which they turned up in Domoticz. (Probably due to the "enabled by default" : false in the template added as all base Shellies will not have the AddOn unit attached to them)

As I already had the device "teached" once I also first removed the related Autodiscovery topics/components as well as the device specific topic and restarted Domoticz to run through a full AutoDiscovery again, that might not be needed when you add the device for the first time.
fantom
Posts: 269
Joined: Thursday 26 March 2015 10:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Poland
Contact:

Re: ShellyTeacher for Domoticz

Post by fantom »

Hi.
I try add my first Sshelly to Domoticz.
Shelly mini PM1 gen3
After all, I see it on devices list. But I don't see it on any tab and on mqtt AD configuration.
What did I do wrong ?
Attachments
3.jpg
3.jpg (40.96 KiB) Viewed 637 times
2.jpg
2.jpg (56.52 KiB) Viewed 637 times
1.PNG
1.PNG (59.37 KiB) Viewed 637 times
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: ShellyTeacher for Domoticz

Post by waltervl »

To get it on a Tab you have to enable it from the device list (click on the green arrow). Then it should show up in the correct tab.

If it is already enabled (blue arrow) you probably have another issue that you have assigned devices to a Domoticz admin user. You should not do that. Check menu setup -users.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
fantom
Posts: 269
Joined: Thursday 26 March 2015 10:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Poland
Contact:

Re: ShellyTeacher for Domoticz

Post by fantom »

I know.
But I don't see this device. On MQTT AD configuration also nothing.
Attachments
4.jpg
4.jpg (35.81 KiB) Viewed 627 times
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: ShellyTeacher for Domoticz

Post by waltervl »

You should see those devices on the Utility Tab. If not check the assigned devices to the current logged in user in menu Setup - Users. If an admin then this assigned devices list should be empty. See also Wiki https://www.domoticz.com/wiki/User_Mana ... et_Devices
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
fantom
Posts: 269
Joined: Thursday 26 March 2015 10:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Poland
Contact:

Re: ShellyTeacher for Domoticz

Post by fantom »

waltervl wrote: Thursday 17 October 2024 23:56 If an admin then this assigned devices list should be empty.
Thanks. This is solution.
Now I see devices.

But still on configuration page for MQTT AD list is empty.
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: ShellyTeacher for Domoticz

Post by waltervl »

That is normal. As written in the MQTT AD gateway page this is only for number devices that can set characteristics of a device (eg motion sensor sensibility). If your MQTT AD devices don't have this functionality that configuration device list is empty.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
amwr
Posts: 20
Joined: Wednesday 28 October 2015 17:48
Target OS: NAS (Synology & others)
Domoticz version:
Location: Switzerland
Contact:

Re: ShellyTeacher for Domoticz

Post by amwr »

Hi all, I need some help with a Shelly Button:
I configured MQTT, used Shelly Teacher to discover and add to Domoticz. Actions work nicely. However, it seems, that event_cnt, which I can clearly see updated on Mosquitto with each button press, is not forwarded to Domoticz.
In other words: A single click on the button, generates "S". The next single click does increase event-cnt in Mosquitto, but it does not change anything in Domoticz, since "S" just remains as it is.

Event log in Domotics confirms this:

Code: Select all

2024-11-10 11:57:03.545 Shelly: Light/Switch/Switch (ShellyButton1 Online)
2024-11-10 11:57:03.648 Shelly: Light/Switch/Switch (ShellyButton1 Online)
2024-11-10 11:57:12.642 Shelly: Light/Switch/Switch (ShellyButton1 Online)
2024-11-10 11:57:12.744 Shelly: Light/Switch/Switch (ShellyButton1 Online)
-> the button connects to WiFi which generates the logs above, but the state "S" is not changed.
Is the inteded behaviour? Do I need to use a combination of "event" and "online" = true to detect a repeated single press of the button?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest