StyraHem / ShellyForHASS

Shelly smart home platform for Home Assistant
MIT License
621 stars 112 forks source link

Version 0.1.6 - entity switch problems #175

Closed antivirus68 closed 4 years ago

antivirus68 commented 4 years ago

HassOS 2.11 HA: 0.104.3 Shelly: 0.1.6 Device: Shelly 1, Shelly 1PM, Shelly 2.5

All three devices have same behaviour, which is the following.

I start from off state. I turn it on, the light goes on, but after few seconds (1/2) the entity switch turns off (light still on) then after about 30secs the entity switch turns on because the light is on.

I start from on state. I turn it off, the light goes off, but after few seconds (1/2) the entity switch turns on (light still off) then after about 30secs the entity switch turns off because the light is off.

I don't get any error in HA log.

Am I doing something wrong or what?

My .yaml file is very basic

shelly:
  version: true

The integration discovers all my shelly devices fine.

Since I'm on a test HA instance I can do as many test as I want.

Thanks Marco...

EDIT: I have done some more tests. I changed scan_interval to 5s and now the switch come back to the correct state after about 5s. Is this the correct behaviour? I mean, is there some side effect with a scan_interval so short? Is this the right solution?

Shelly 1 discover is CoAP Shelly 1PM are mDns Shelly 2.5 CoAP

pavolholes commented 4 years ago

I just installed this plugin and I'm having the same behaviour issue with the Shelly Dimmer.

JesCR commented 4 years ago

Same here with a shelly1 and a shelly2.

dborsnich commented 4 years ago

I´ve have issues with the new version. All off my shellies devices doesn´t appear. I´ve lights and dimmers I came back to the 1.5 version and now is ok. My HA version is 0.103.5, thanks

pavolholes commented 4 years ago

Thanks @dborsnich for your comment, I didn't know I can go to older version in HACS. I just did that and folder root\config\custom_components\shelly disappeared :( So I "updated" back to 0.1.6 and it appeared back on the disk...

chemelli74 commented 4 years ago

My HA version is 0.103.5, thanks

0.1.6 needs at least 0.104.0. If using HACS you are blocked from upgrading plugin if HA is not compliant.

Simone

skeptizzle commented 4 years ago

@chemelli74

0.1.6 needs at least 0.104.0. If using HACS you are blocked from upgrading plugin if HA is not compliant.

Simone

I'm running Home Assistant (non-Core) 0.98.5 and using ShellyForHass through HACS. I had no problem upgrading to 0.1.6, and now i'm left with: "Unable to import shelly: cannot import name 'ATTR_RESTORED' from 'homeassistant.helpers.entity_registry' (/usr/src/homeassistant/homeassistant/helpers/entity_registry.py)" The above seem to make ALL my Shelly units unavailable.

I guess i will have to update Home Assistant when i get home...

chemelli74 commented 4 years ago

@antivirus68, @pavolholes, @JesCR please share a debug log. Be aware that it can be really verbose.

Simone

antivirus68 commented 4 years ago

Here is some log.

Just some more info:

I didn't set any scan_interval, I left the default.

I set the logger:

logger:
  default: info
  logs:
    custom_components.shelly: debug

Shelly 2.5 E66FBE-1 is detected with mDns Shelly 1PM 76C246 is detected with CoAP-discovery Shelly 1PM 76AFA4 is detected with mDns Shelly 1 93B635 is detected with mDns

I have turned on and off the Shelly 1PM 76C246, and the switch is updated only after about 30sec.

2020-02-20 19:07:39 INFO (Thread-15) [pyShelly] Get status from 76AFA4 Shelly 1 PM - 76AFA4
2020-02-20 19:07:39 INFO (Thread-16) [pyShelly] Get status from 93B635 Shelly 1 - 93B635
2020-02-20 19:07:39 INFO (Thread-17) [pyShelly] Get status from E66FBE Shelly 2.5 - E66FBE
2020-02-20 19:07:39 INFO (Thread-16) [pyShelly] Update id:93B635 state:False stateValue:None values:None info_values:{'current_consumption': 0, 'switch': True}
2020-02-20 19:07:39 INFO (Thread-16) [pyShelly] Update id:93B635 state:True stateValue:None values:None info_values:None
2020-02-20 19:07:39 INFO (Thread-15) [pyShelly] Update id:76AFA4 state:False stateValue:None values:None info_values:{'over_power': False, 'current_consumption': 0, 'total_consumption': 59, 'switch': False}
2020-02-20 19:07:39 INFO (Thread-15) [pyShelly] Update id:76AFA4 state:0.0 stateValue:None values:None info_values:{'total_consumption': 59}
2020-02-20 19:07:39 INFO (Thread-15) [pyShelly] Update id:76AFA4 state:False stateValue:None values:None info_values:None
2020-02-20 19:07:39 INFO (Thread-17) [pyShelly] Update id:E66FBE-1 state:False stateValue:None values:None info_values:{'over_power': False, 'current_consumption': 0, 'total_consumption': 628, 'switch': True}
2020-02-20 19:07:39 INFO (Thread-17) [pyShelly] Update id:E66FBE-2 state:False stateValue:None values:None info_values:{'over_power': False, 'current_consumption': 0, 'total_consumption': 215, 'switch': False}
2020-02-20 19:07:39 INFO (Thread-17) [pyShelly] Update id:E66FBE-1 state:0.0 stateValue:None values:None info_values:{'total_consumption': 628}
2020-02-20 19:07:39 INFO (Thread-17) [pyShelly] Update id:E66FBE-2 state:0.0 stateValue:None values:None info_values:{'total_consumption': 215}
2020-02-20 19:07:39 INFO (Thread-17) [pyShelly] Update id:E66FBE-1 state:True stateValue:None values:None info_values:None
2020-02-20 19:07:39 INFO (Thread-17) [pyShelly] Update id:E66FBE-2 state:False stateValue:None values:None info_values:None
2020-02-20 19:07:47 INFO (Thread-18) [pyShelly] Get status from 76C246 Shelly 1 PM - 76C246
2020-02-20 19:07:47 INFO (Thread-18) [pyShelly] Update id:76C246 state:False stateValue:None values:None info_values:{'over_power': False, 'current_consumption': 0, 'total_consumption': 633, 'switch': False}
2020-02-20 19:07:47 INFO (Thread-18) [pyShelly] Update id:76C246 state:0.0 stateValue:None values:None info_values:{'total_consumption': 633}
2020-02-20 19:07:47 INFO (Thread-18) [pyShelly] Update id:76C246 state:False stateValue:None values:None info_values:None
2020-02-20 19:08:39 INFO (Thread-19) [pyShelly] Get status from 76AFA4 Shelly 1 PM - 76AFA4
2020-02-20 19:08:39 INFO (Thread-20) [pyShelly] Get status from 93B635 Shelly 1 - 93B635
2020-02-20 19:08:39 INFO (Thread-21) [pyShelly] Get status from E66FBE Shelly 2.5 - E66FBE
2020-02-20 19:08:40 INFO (Thread-21) [pyShelly] Update id:E66FBE-1 state:False stateValue:None values:None info_values:{'over_power': False, 'current_consumption': 0, 'total_consumption': 628, 'switch': True}
2020-02-20 19:08:40 INFO (Thread-21) [pyShelly] Update id:E66FBE-2 state:False stateValue:None values:None info_values:{'over_power': False, 'current_consumption': 0, 'total_consumption': 215, 'switch': False}
2020-02-20 19:08:40 INFO (Thread-21) [pyShelly] Update id:E66FBE-1 state:0.0 stateValue:None values:None info_values:{'total_consumption': 628}
2020-02-20 19:08:40 INFO (Thread-21) [pyShelly] Update id:E66FBE-2 state:0.0 stateValue:None values:None info_values:{'total_consumption': 215}
2020-02-20 19:08:40 INFO (Thread-21) [pyShelly] Update id:E66FBE-1 state:True stateValue:None values:None info_values:None
2020-02-20 19:08:40 INFO (Thread-21) [pyShelly] Update id:E66FBE-2 state:False stateValue:None values:None info_values:None
2020-02-20 19:08:40 INFO (Thread-20) [pyShelly] Update id:93B635 state:False stateValue:None values:None info_values:{'current_consumption': 0, 'switch': True}
2020-02-20 19:08:40 INFO (Thread-20) [pyShelly] Update id:93B635 state:True stateValue:None values:None info_values:None
2020-02-20 19:08:40 INFO (Thread-19) [pyShelly] Update id:76AFA4 state:False stateValue:None values:None info_values:{'over_power': False, 'current_consumption': 0, 'total_consumption': 59, 'switch': False}
2020-02-20 19:08:40 INFO (Thread-19) [pyShelly] Update id:76AFA4 state:0.0 stateValue:None values:None info_values:{'total_consumption': 59}
2020-02-20 19:08:40 INFO (Thread-19) [pyShelly] Update id:76AFA4 state:False stateValue:None values:None info_values:None
InToSSH commented 4 years ago

Hi, I have exactly the same problem, all Shelly 1s discovered via mDNS. I am on a plugin v1.6.0 and HA v0.106.2, Shelly FW 20200206-083100/v1.5.10@e6a4205e. Also those Shellies are missing RSSI value and I think also few other values. I know the Features list said that mDNS will have slower status update response than CoAP, but I don't know what to do to make CoAP work, or if adding the device directly via IP address will make it faster.

EDIT: Using the IP directly doesn't make any difference. Those delays in status update can be up to 55s, which is a huge delay. This makes using any automations based on the state almost unusable. My shellies are on an IoT VLAN and different subnet, but HA has direct access to this network via an interface on the VM.

chemelli74 commented 4 years ago

Please update to latest beta and recheck.

Simone

antivirus68 commented 4 years ago

I've tried ShellyForHASS-0.1.7-beta.2 but I don't see any significant change. Always a big delay on a switch discovered with CoAP protocol.

Marco

ttajmajer commented 4 years ago

Similar effect here, I've added this to my config and it is a bit better, but still laggy:

igmp_fix: 'true' scan_interval: 2

chemelli74 commented 4 years ago

@antivirus68, @ttajmajer after upgrading to 0.1.7.b2 what shows the entry "protocols" for those entities ?

Simone

antivirus68 commented 4 years ago

CoAP protocol

chemelli74 commented 4 years ago

CoAP protocol

Please post the exact list of protocols. Thank you,

Simone

antivirus68 commented 4 years ago

CoAP protocol

Please post the exact list of protocols. Thank you,

Simone

one Shelly One protocols mDns, poll one Shelly PM protocols mDns, poll, CoAP-discovery another Shelly PM protocols mDns, poll, CoAP-discovery one Shelly 2.5 protocols CoAP-discovery, poll, mDns

Hope this can help

chemelli74 commented 4 years ago

You always miss "CoAP-msg". If you don't receive CoAP messages, you won't have reall time.

Unfortunately it's a common and not easy to fix network issue.

Simone

antivirus68 commented 4 years ago

You always miss "CoAP-msg". If you don't receive CoAP messages, you won't have reall time.

Unfortunately it's a common and not easy to fix network issue.

Simone

Ok, just to be sure to understood. If in protocols I don't get "CoAP-msg" the real time behaviour can't work, right? And is there something I can check on my network to fix this? or are you saying it is pretty random problem to solve?

Thanks Marco

chemelli74 commented 4 years ago

You always miss "CoAP-msg". If you don't receive CoAP messages, you won't have reall time. Unfortunately it's a common and not easy to fix network issue. Simone

Ok, just to be sure to understood. If in protocols I don't get "CoAP-msg" the real time behaviour can't work, right? And is there something I can check on my network to fix this? or are you saying it is pretty random problem to solve?

Thanks Marco

Marco,

it depends on access point, router and their configuration. I suggest you post on Facebook: https://www.facebook.com/groups/shellyforhass

Simone

InToSSH commented 4 years ago

Just reporting the status with the beta update, same thing as Marco's. I just have the CoAP-discovery and poll, when I specify host_ip (due to having multiple NICs on the HA VM), otherwise mDNS only. I tried different settings on my Unifi AP Pro and Switch, but couldn't get it working. The OpenWRT router is not in the way of the communication, so I didn't try anything with it.

ttajmajer commented 4 years ago

In my case, the protocols are: protocols CoAP-discovery, poll, IP-addr

so I assume that the problem is with lack of CoAP-msg. Strangely I also use Unify gear in my network.

InToSSH commented 4 years ago

@ttajmajer I have read somewhere that to allow the CoAP messages you need to disable this "Enable IGMP Snooping" in the Edit Network settings, for the network used to communicate with Shellies. This however didn't work for me.. Might be worth asking about this in the UBNT community.

ttajmajer commented 4 years ago

I'm trying to investigate this. Do you know if shelly devices are possibly trying to use IPv6 for sending CoAP datagrams? IPv6 is native IP for CoAP and while the nodes are accessible by IPv4, they may try to send messages via IPv6, if the router assigned an address to them.

InToSSH commented 4 years ago

Hmm.. I just checked my router and the DHCPv6 is disabled for my IoT and NoT VLANs (verified with my phone connecting to those networks), so Shellies should only have IPv4. On Unifi the DHCP is disabled altogether (not sure if it would even work without USG)

chemelli74 commented 4 years ago

I'm going to close this issue based also on our new FAQ: https://github.com/StyraHem/ShellyForHASS/wiki/FAQ2:-Slow-updates-of-lovelave-UI

Please continue the discussion on our Facebook group.

Simone