bieniu / ha-shellies-discovery-gen2

Script that adds MQTT discovery support for Shellies Gen2 devices
Apache License 2.0
101 stars 18 forks source link

No devices or entities found in MQTT in Home assistant #396

Closed nemihome closed 6 months ago

nemihome commented 6 months ago

Describe the bug

Auto descovery does not seem to work because there are no devices or entities shown in MQTT in home assistant.

As you can see below MQTT Broker is working, values are visible there, announce is working even shellies_discovery is showijng entries. Configuration.yaml seems to work. Script also seems to be running (first I did it with the default entries and they also showed up in MQTT broker)

Expected behavior

Shelly devices should be auto discovered

Additional Info: I'm using core version of Home Assistant. So I had to do some more manual steps like installing mosquitto broker via apt and also creating the python script manually in the folder config\python_scripts

Troubleshooting checklist: correct MQTT configuration in Home Assistant with discovery enabled - It is automatically enabled _same discoveryprefix in Home Assistant configuration and in script configuration - Standard homeassistant like in your script Shellies firmware updated to current version - it is Home Assistant updated to current version - it is enabled MQTT in Shellies configuration - it is when I rund MQTT Explorer I'm getting the following:

shellypro3em-34917a45b630/status/em:0 {"id":0,"a_current":0.029,"a_voltage":231.8,"a_act_power":0.0,"a_aprt_power":6.6,"a_pf":0.00,"a_freq":50.0,"b_current":0.067,"b_voltage":230.6,"b_act_power":9.6,"b_aprt_power":15.4,"b_pf":0.59,"b_freq":50.0,"c_current":0.029,"c_voltage":230.5,"c_act_power":0.0,"c_aprt_power":6.7,"c_pf":0.00,"c_freq":50.0,"n_current":0.067,"total_current":0.125,"total_act_power":9.572,"total_aprt_power":28.800, "user_calibrated_phase":["n"]}

shellies/announce {"name":null,"id":"shellypro3em-34917a45b630","mac":"34917A45B630","slot":0,"model":"SPEM-003CEBEU","gen":2,"fw_id":"20240223-141900/1.2.2-g7c39781","ver":"1.2.2","app":"Pro3EM","auth_en":false,"auth_domain":null,"profile":"triphase"}

{"id":1,"src":"shellypro3em-34917a45b630","dst":"shellies_discovery","result":{"ble":{"enable":false,"rpc":{"enable":false},"observer":{"enable":false}},"cloud":{"enable":true,"server":"shelly-99-eu.shelly.cloud:6022/jrpc"},"em:0":{"id":0, "name":"Wärmepumpe","blink_mode_selector":"active_energy" ,"phase_selector":"all", "monitor_phase_sequence":true,"reverse":{}},"emdata:0":{},"eth":{"enable":true,"ipv4mode":"dhcp","ip":null,"netmask":null,"gw":null,"nameserver":null},"modbus":{"enable":true},"mqtt":{"enable":true,"server":"192.168.181.100:1883","client_id":"shellypro3em-34917a45b630","user":"mosquitto","ssl_ca":null,"topic_prefix":"shellypro3em-34917a45b630","rpc_ntf":true,"status_ntf":true,"use_client_cert":false,"enable_rpc":true,"enable_control":true},"sys":{"device":{"name":null,"mac":"34917A15B630","fw_id":"20240223-141900/1.2.2-g7c39781","discoverable":true,"eco_mode":false,"profile":"triphase","addon_type":null},"location":{"tz":"Europe/Berlin","lat":23.118100,"lon":113.253900},"debug":{"level":2,"file_level":null,"mqtt":{"enable":false},"websocket":{"enable":false},"udp":{"addr":null}},"ui_data":{},"rpc_udp":{"dst_addr":null,"listen_port":null},"sntp":{"server":"time.google.com"},"cfg_rev":25},"temperature:0":{"id":0, "name":null, "report_thr_C": 5.0, "offset_C": 0.0},"wifi":{"ap":{"ssid":"ShellyPro3EM-34917A45B630","is_open":false, "enable":false, "range_extender": {"enable":false}},"sta":{"ssid":null,"is_open":true, "enable":false, "ipv4mode":"dhcp","ip":null,"netmask":null,"gw":null,"nameserver":null},"sta1":{"ssid":null,"is_open":true, "enable":false, "ipv4mode":"dhcp","ip":null,"netmask":null,"gw":null,"nameserver":null},"roam":{"rssi_thr":-80,"interval":60}},"ws":{"enable":false,"server":null,"ssl_ca":"ca.pem"}}}

_properly configured pythonscript component - Should be the hello world example script is wrting to the log so basically script seems to work. Your script also seems to be working in general otherwise the shellies_discovery entry would not exist.

For the device to work with the script, it must have MQTT configured and options Enable "MQTT Control", RPC status notifications over MQTT and Generic status update over MQTT enabled. - Done

Versions:

Configuration yaml:

Loads default set of integrations. Do not remove.

default_config:

Load frontend themes from the themes folder

frontend: themes: !include_dir_merge_named themes

automation: !include automations.yaml script: !include scripts.yaml scene: !include scenes.yaml

python_script:

logger: default: error logs: homeassistant.components.python_script: debug homeassistant.components.automation: info homeassistant.components.mqtt.discovery: inf

Debug log:

2024-03-30 17:35:45.274 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Shellies Announce Gen2: Running automation actions 2024-03-30 17:35:45.274 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Shellies Announce Gen2: Repeating sequence: Iteration 1 of 1 with item: 'shellypro3em-34917a45b630' 2024-03-30 17:35:45.275 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Initialized trigger Shellies Announce Gen2 2024-03-30 17:35:45.275 INFO (MainThread) [homeassistant.components.automation.shellies_discovery_gen2] Initialized trigger Shellies Discovery Gen2 2024-03-30 17:35:45.276 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Shellies Announce Gen2: Repeat at step 1: Running automation actions 2024-03-30 17:35:45.277 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Shellies Announce Gen2: Repeat at step 1: Executing step call service


When I restart with Home Assistant with debugging enabled in MQTT I'm getting the following result:

2024-03-30 18:22:11.694 DEBUG (MainThread) [homeassistant.components.mqtt.client] Transmitting message on shellypro3em-34917a45b630/rpc: '{"id":1,"src":"shellies_discovery","method":"Shelly.GetConfig"}', mid: 1, qos: 0 2024-03-30 18:22:12.678 DEBUG (MainThread) [homeassistant.components.mqtt.client] Subscribing to homeassistant/+/+/config, mid: 2, qos: 0 2024-03-30 18:22:12.679 DEBUG (MainThread) [homeassistant.components.mqtt.client] Subscribing to homeassistant/+/+/+/config, mid: 2, qos: 0 2024-03-30 18:22:12.679 DEBUG (MainThread) [homeassistant.components.mqtt.client] Subscribing to dsmr/#, mid: 2, qos: 0 2024-03-30 18:22:12.679 DEBUG (MainThread) [homeassistant.components.mqtt.client] Subscribing to fully/deviceInfo/+, mid: 2, qos: 0 2024-03-30 18:22:12.679 DEBUG (MainThread) [homeassistant.components.mqtt.client] Subscribing to tasmota/discovery/#, mid: 2, qos: 0 2024-03-30 18:22:12.679 DEBUG (MainThread) [homeassistant.components.mqtt.client] Subscribing to shellies_discovery/rpc, mid: 2, qos: 0 2024-03-30 18:22:14.682 DEBUG (MainThread) [homeassistant.components.mqtt.client] Transmitting message on homeassistant/status: 'online', mid: 3, qos: 0



![actions](https://github.com/bieniu/ha-shellies-discovery-gen2/assets/60146462/f5a4d2b4-7b4f-45bc-97bd-dffdc0c9e844)
![MQTT](https://github.com/bieniu/ha-shellies-discovery-gen2/assets/60146462/757fbe87-9736-4d4b-9eca-0e9be2c05487)
bieniu commented 6 months ago

You opened an issue in the Shellies Discovery Gen2 repository and showed your Shellies Discovery (Gen1) automations. I don't know if your configuration is wrong or if you made a mistake filling out the form. Also the logs are incomplete.

Please fill in the issue correctly or it will be closed.

nemihome commented 6 months ago

Sorry, made a mistake filling out the form. Started with the Gen 1 script and realized that's the wrong one for my Shelly and started again. There are no more infos in the logs.

nemihome commented 6 months ago

Well this seems to be a problem that the call does not work at startup of Home assistant. I executed the first action (announce) manually after startup. In this case it seems to work and the log is flooded with information.

bieniu commented 6 months ago

There are no more infos in the logs.

And where is the log?

nemihome commented 6 months ago

The log is in the first post as mentioned above.

Now it is working because I started the discovery manually. But this action is not running at startup as you can see in the screenshot.

2024-03-31 12:44:25.214 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Shellies Announce Gen2: Running automation actions
2024-03-31 12:44:25.215 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Shellies Announce Gen2: Repeating sequence: Iteration 1 of 1 with item: 'shellypro3em-34917a45b630'
2024-03-31 12:44:25.215 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Initialized trigger Shellies Announce Gen2
2024-03-31 12:44:25.215 INFO (MainThread) [homeassistant.components.automation.shellies_discovery_gen2] Initialized trigger Shellies Discovery Gen2
2024-03-31 12:44:25.219 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Shellies Announce Gen2: Repeat at step 1: Running automation actions
2024-03-31 12:44:25.219 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Shellies Announce Gen2: Repeat at step 1: Executing step call service
2024-03-31 12:44:26.213 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-a-active_power
2024-03-31 12:44:26.214 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-a-apparent_power
2024-03-31 12:44:26.214 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-a-current
2024-03-31 12:44:26.231 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-a-power_factor
2024-03-31 12:44:26.253 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-a-total_active_energy
2024-03-31 12:44:26.256 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-a-total_active_returned_energy
2024-03-31 12:44:26.256 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-a-voltage
2024-03-31 12:44:26.265 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-a-frequency
2024-03-31 12:44:26.266 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-b-active_power
2024-03-31 12:44:26.266 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-b-apparent_power
2024-03-31 12:44:26.266 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-b-current
2024-03-31 12:44:26.266 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-b-power_factor
2024-03-31 12:44:26.266 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-b-total_active_energy
2024-03-31 12:44:26.278 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-b-total_active_returned_energy
2024-03-31 12:44:26.283 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-b-voltage
2024-03-31 12:44:26.286 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-b-frequency
2024-03-31 12:44:26.292 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-c-active_power
2024-03-31 12:44:26.297 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-c-apparent_power
2024-03-31 12:44:26.301 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-c-current
2024-03-31 12:44:26.305 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-c-power_factor
2024-03-31 12:44:26.309 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-c-total_active_energy
2024-03-31 12:44:26.315 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-c-total_active_returned_energy
2024-03-31 12:44:26.318 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-c-voltage
2024-03-31 12:44:26.322 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-0-c-frequency
2024-03-31 12:44:26.327 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-eth_ip
2024-03-31 12:44:26.328 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-last_restart
2024-03-31 12:44:26.334 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-ssid
2024-03-31 12:44:26.335 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-wifi_ip
2024-03-31 12:44:26.342 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-wifi_signal
2024-03-31 12:44:26.346 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-n_current
2024-03-31 12:44:26.350 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-device_temperature
2024-03-31 12:44:26.353 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-total_current
2024-03-31 12:44:26.358 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-total_active_power
2024-03-31 12:44:26.358 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-total_apparent_power
2024-03-31 12:44:26.361 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-total_active_energy
2024-03-31 12:44:26.361 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor shellypro3em-34917a45b630-total_active_returned_energy
2024-03-31 12:44:26.361 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: button shellypro3em-34917a45b630-restart
2024-03-31 12:44:26.362 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: update shellypro3em-34917a45b630-firmware
2024-03-31 12:44:26.376 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: update shellypro3em-34917a45b630-firmware_beta
2024-03-31 12:44:26.382 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: binary_sensor shellypro3em-34917a45b630-cloud

startup

I think until the sensor is available it takes some time after startup therefore there is no answer and due to that the second automation step is not working and that is not visible in the log.

bieniu commented 6 months ago

You are the system administrator and you are responsible for the automation and correctness of their operation.