bieniu / ha-shellies-discovery

Script that adds MQTT discovery support for Shellies devices
Apache License 2.0
295 stars 90 forks source link

Input states not working for Shelly 1PM #220

Closed ghost closed 2 years ago

ghost commented 2 years ago

Describe the bug Missing input states for Shelly 1PM and device triggers not usable for input events.

Expected behavior Input states of Shelly 1PM updating when toggling the physical switch. Device triggers (input turned on/off) usable in automations.

Versions:

Shellies Discovery automation:

alias: 'MQTT: Shellies Discovery'
description: ''
trigger:
  - platform: mqtt
    topic: shellies/announce
condition: []
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 }}'
      mode: '{{ trigger.payload_json.mode | default }}'
      host: '{{ trigger.payload_json.ip }}'
mode: queued
max: 999
rubendejong commented 2 years ago

Same applies to Shelly i3 devices. I think it's because the input topics have been changed in #216, as a result the topic of the binary_sensor is something like shellies/shelly-i3-hal/~input/0 which does not exist. The ~ should not be there.

bieniu commented 2 years ago

This should be fixed in 0.43.1. Please run announce automation, restart HA and check once again.

ghost commented 2 years ago

Both 1PMs still not working after announce and HA reboot (and Shelly reboot, just to be safe). The input states are still changing in the shellies MQTT topics but not in the homeassistant ones.

ghost commented 2 years ago

I just tried something. With version 0.43.0 the 1PMs work, but the i3 and Button 1s don't. With version 0.43.1 the i3 and Button 1s work again, but the 1PMs fail.

bieniu commented 2 years ago

I tested 1PM, i3 and Button1 with 0.43.1 and all topics are correct. You have to run the announce automation to fix the problem.

ghost commented 2 years ago

Just tried the announce automation again without success. The 1PMs switch input states still don't work with 0.43.1. When rolling back to 0.42.9 and 0.43.0 they work as expected. As soon as the 0.43.1 is in use they don't - even after announce automation, reboot and so on.

bieniu commented 2 years ago

Debug log for python_script please

ghost commented 2 years ago

debug.log Log after triggering announce automation and turning switch on and off (switch in detached mode).

bieniu commented 2 years ago

I don't see any problem in the log.

ghost commented 2 years ago

In the shellies 1PM input 0 mqtt topic the state changes from 0 to 1 as expected. In HA it stays off permanently. mqtt

ghost commented 2 years ago

I think, i've got it. The homeassistant mqtt topic for the 1PM has the following config payload:

{"name": "Shelly 1PM E8DB84D33B11 Input 0", "stat_t": "input/0", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false", "uniq_id": "shelly1pm-e8db84d33b11-input-0", "qos": 0, "dev": {"cns": [["mac", "e8:db:84:d3:3b:11"]], "name": "Shelly 1PM E8DB84D33B11", "mdl": "Shelly 1PM", "sw": "20211109-130756/v1.11.7-g682a0db", "mf": "Allterco Robotics", "cu": "http://192.168.178.33/"}, "~": "shellies/shelly1pm-E8DB84D33B11/", "pl_on": "1", "pl_off": "0"}

If I change "input/0" to "~input/0" by publishing it manually, the entity works again - until the topic is updated.

bieniu commented 2 years ago

Closed via https://github.com/bieniu/ha-shellies-discovery/pull/221

@Eyco1981 Thanks for debugging

rubendejong commented 2 years ago

Confirmed that inputs for i3 work aswell after updating to 0.43.1. I was still on 0.43.0, shame on me. Thanks a lot for writing this script and support!

bieniu commented 2 years ago

0.43.2 released, please update.