StyraHem / ShellyForHASS

Shelly smart home platform for Home Assistant
MIT License
620 stars 111 forks source link

[BUG] Shelly 2.5 entities unavailable #531

Open bulburDE opened 3 years ago

bulburDE commented 3 years ago

Environment

Describe the bug

It happens that a shelly dimmer 2.5 (v.1.9.4) which is configured as a roller shutter, that a subset of the entities become unavailable. At the moment I have a device where the following entities are unavailable:

The following entities are still available:

I renamed all the entities manually. It seems to me that the "general" entities for the device are available and the ones specific to an actor or sensor are unavailable, but I don't know if that is a valid classification and if it has been the same entities that were unavailable in the past. For the cover entity I am certain that is has been affected when I previously encountered this bug.

The available entities are getting regular updated values. Restarting home assistant doesn't seem to recover the unavailable ones. The only thing helping is to reboot the device. Then all entities will be available for a while until it happens again.

I encountered this bug with another device in the previous weeks. To find a solution, today, I did a factory reset on the device and deleted the ShellyForHass integration and readded it, then renamed the enitites to the old values (so that my automations can use it again). The previously affected device is fine at the moment (since it was a few hours ago that may change), but now the device listed above has the same symptoms.

I've found the following log message: 2021-03-07 17:19:17 ERROR (CoAP) [pyShelly] Timeout connecting to http://192.168.90.80/settings [shellyswitch25-73C35E.fritz.box] Since that timestamp the device is unavailable. I couldn't find log entries for that ip after that entry.

The web ui of the shelly is available and I can also access /settings and /status.

Steps to Reproduce

Wait a few days until some device has entities that are unavailable.

Expected behavior

Obviously, all entities should be available.

Screenshots

cover_entity entity_list

Traceback/Error logs

Additional context

status.json.txt settings.json.txt

bulburDE commented 3 years ago

After I rebooted the device and restarted home assistant yesterday, the device is now fully available again. But two other devices are showing the same symptoms. As suggested in the FAQ I've checked from my raspberry pi where home assistant is running if CoAP messages are sent. I can see that both devices are sending messages regularly. Which is not surprising since as stated a subset of the entities are working normally. To restore the full functionality of the device it is not enough to reboot the device, home assistant has to be restarted too. I've enabled the debug logs for pyShelly a few minutes ago and now I could see the following entries for the malfunctioning devices (192.168.90.81 and 192.168.90.88):

2021-03-08 21:43:41 ERROR (CoAP) [pyShelly] Error http GET: http://192.168.90.88/settings, IncompleteRead(0 bytes read, 2841 more expected), Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/pyShelly/utils.py", line 61, in shelly_http_get
body = resp.read()
File "/usr/local/lib/python3.8/http/client.py", line 471, in read
s = self._safe_read(self.length)
File "/usr/local/lib/python3.8/http/client.py", line 614, in _safe_read
raise IncompleteRead(data, amt-len(data))
http.client.IncompleteRead: IncompleteRead(0 bytes read, 2841 more expected)
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/pyShelly/utils.py", line 61, in shelly_http_get
body = resp.read()
File "/usr/local/lib/python3.8/http/client.py", line 471, in read
s = self._safe_read(self.length)
File "/usr/local/lib/python3.8/http/client.py", line 614, in _safe_read
raise IncompleteRead(data, amt-len(data))
http.client.IncompleteRead: IncompleteRead(0 bytes read, 2841 more expected)
2021-03-08 21:43:32 DEBUG (CoAP) [pyShelly] http://192.168.90.81/settings
2021-03-08 21:43:34 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 130, in async_init
result = await self._async_handle_step(
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 213, in _async_handle_step
result: Dict = await getattr(flow, method)(user_input)
File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 325, in async_step_discovery
return await self.async_step_pick_implementation()
File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 250, in async_step_pick_implementation
return await self.async_step_auth()
File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 274, in async_step_auth
url = await self.flow_impl.async_generate_authorize_url(self.flow_id)
File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 147, in async_generate_authorize_url
redirect_uri = self.redirect_uri
File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 131, in redirect_uri
raise RuntimeError("No current request in context")
RuntimeError: No current request in context
...
...
...
2021-03-08 21:43:37 ERROR (CoAP) [pyShelly] Timeout connecting to http://192.168.90.81/settings [shellyswitch25-7378DF.fritz.box]

Then I checked and couldn't access /settings for both devices. /status was accessible. So that may explain why a shelly and a home assistant reboot is required:

I haven't looked into the ShellyForHASS code enough to understand if it is intended that /settings is only reread at start.

QuakeGio83 commented 3 years ago

I have same issue. Hope that can be fixed soon

sir106 commented 3 years ago

looks like the latest upgrades the 2.5 shelly is integrated as "SWITCH" ... did not find a way (even by manually adding them via configuration.yaml) to add them as COVERS.

CONFIGURATION.YAML

    ## E4F8A3 - WOHNZIMMER JALOUSIE (.60)
    - id: "E4F8A3" 
      entity_id: "wohnzimmer_jalousie"
      light_switch: false
      name: "Wohnzimmer Jalousie" #set friendly name

...creates 2 binary_sensors for switches only:

shelly_type: Shelly 2.5
shelly_id: E4F8A3-2
ip_address: 192.168.33.60
friendly_name: Wohnzimmer Jalousie - Switch
icon: 'mdi:light-switch'
hakana commented 3 years ago

It gets the information about if it is a cover by polling the /setting URL. But as it got a timeout it can't determine if it is a cover or switch.

Can you call the URL above if you use wget from an ssh session under HA environment?

QuakeGio83 commented 3 years ago

In my case my problem was solved automatically (the cover shelly 2.5 now works).

sir106 commented 3 years ago

It gets the information about if it is a cover by polling the /setting URL. But as it got a timeout it can't determine if it is a cover or switch.

Can you call the URL above if you use wget from an ssh session under HA environment?

yes - it is accessible:

{"device":{"type":"SHSW-25","mac":"BCDDC2775FAE","hostname":"shellyswitch25-BCDDC2775FAE","num_outputs":2, "num_meters":2, "num_rollers":1},"wifi_ap":{"enabled":false,"ssid":"shellyswitch25-BCDDC2775FAE","key":""},"wifi_sta":{"enabled":true,"ssid":"XYZ","ipv4_method":"static","ip":"192.168.11.56","gw":"192.168.11.1","mask":"255.255.255.0","dns":null},"wifi_sta1":{"enabled":true,"ssid":"Recovery","ipv4_method":"dhcp","ip":null,"gw":null,"mask":null,"dns":null},"ap_roaming":{"enabled":false,"threshold":-70},"mqtt": {"enable":true,"server":"192.168.11.48:1883","user":"mqtt","id":"shellyswitch25-BCDDC2775FAE","reconnect_timeout_max":60.000000,"reconnect_timeout_min":2.000000,"clean_session":true,"keep_alive":60,"max_qos":0,"retain":true,"update_period":30},"coiot": {"enabled":true,"update_period":15,"peer":""},"sntp":{"server":"time.google.com","enabled":true},"login":{"enabled":false,"unprotected":false,"username":"XYZ"},"pin_code":"","name":"Arbeitszimmer Fenster","fw":"20210323-104714/v1.10.1-gf276b51","factory_reset_from_switch":true,"discoverable":true,"build_info":{"build_id":"20210323-104714/v1.10.1-gf276b51","build_timestamp":"2021-03-23T10:47:14Z","build_version":"1.0"},"cloud":{"enabled":false,"connected":false},"timezone":"Europe/Berlin","lat":49.865711,"lng":8.626040,"tzautodetect":true,"tz_utc_offset":7200,"tz_dst":false,"tz_dst_auto":true,"time":"02:09","unixtime":1617926974,"led_status_disable":false,"debug_enable":false,"allow_cross_origin":false,"actions":{"active":false,"names":["btn_on_url","btn_off_url","longpush_url","shortpush_url","out_on_url","out_off_url","btn_on_url","btn_off_url","longpush_url","shortpush_url","out_on_url","out_off_url","roller_open_url","roller_close_url","roller_stop_url"]},"hwinfo":{"hw_revision":"prod-191217", "batch_id":1},"mode":"roller","max_power":500,"longpush_time":800,"relays":[{"name":null,"appliance_type":"General","ison":false,"has_timer":false,"default_state":"switch","btn_type":"toggle","btn_reverse":0,"auto_on":0.00,"auto_off":0.00,"max_power":0,"schedule":false,"schedule_rules":[]},{"name":null,"appliance_type":"General","ison":false,"has_timer":false,"default_state":"switch","btn_type":"toggle","btn_reverse":0,"auto_on":0.00,"auto_off":0.00,"max_power":0,"schedule":false,"schedule_rules":[]}],"rollers":[{"maxtime":20.00,"maxtime_open":60.00,"maxtime_close":60.00,"default_state":"stop","swap":false,"swap_inputs":false,"input_mode":"openclose","button_type":"momentary","btn_reverse":0,"state":"stop","power":0.00,"is_valid":true,"safety_switch":false,"schedule":false,"schedule_rules":[],"obstacle_mode":"disabled","obstacle_action":"stop","obstacle_power":200,"obstacle_delay":1,"safety_mode":"while_opening","safety_action":"stop","safety_allowed_on_trigger":"none","off_power":2,"positioning":true}],"favorites_enabled":false,"favorites":[{"name":"Position 1","pos":0},{"name":"Position 2","pos":0},{"name":"Position 3","pos":0},{"name":"Position 4","pos":0}],"wifirecovery_reboot_enabled":true}

pschneider87 commented 3 years ago

I have the same problem. All my Shelly 2.5 have unavailable entities while some of them provide data. Other Shellys (1, 1PM) just work fine. Any help is much appreciated!

pschneider87 commented 3 years ago

any ideas? I can't use my shelly 2.5 in my home assistant because they all got unavailable :-(

welcoMattic commented 3 years ago

Same issue here: Shelly 2.5 is not available in HA for weeks. I've tried many fixes:

Nothing makes the shelly available again :(

TK2020git commented 3 years ago

Hey, I have this issue at one of my shelly 2.5. It is configured as roller but the cover buttons/entities are not available/showing. The others are working fine, same configuration. If I use the HA onboard shelly integration it is also available as roller. If I'm right, the roller mode can only configured on the device self? Did you try using the HA onboard integration? I would prefer to use only one integration :-)

welcoMattic commented 3 years ago

I fixed the problem by declaring manually the ips of my shellies in HA configuration

TK2020git commented 3 years ago

That will be an easy solution. So you do the configuration in the configuration.yaml?

Like this:

"shelly: discover_by_ip:

TK2020git commented 3 years ago

I can't find the solution. Each time I installed ShellyForHass, the Entities for the roller mode (see below) are not available. I would use the internal intergration but I also like to use the Shelly Button 1, which is not supported.

Shelly 2 5 roller mode

pschneider87 commented 3 years ago

it's working with yaml-configuration by setting the IPs manually, but this will duplicate all shellys. Is any developer aware of this issue?

BarBaar44 commented 3 years ago

Same issue here...

Reinstalling the Shelly plugin in HA fixes the issue temporarily.

Would love to have this fixed!

Naesstrom commented 3 years ago

Same problem for me with the 2.5, gets unavailable after a few days! image

janbernhardt commented 3 years ago

I have the same issue, all of my 2.5 shellies only show sensor entities, but no switches to change the state.

RainOrigami commented 1 year ago

Hello, same issue where initially my Shelly 2.5 was set to relay mode, which worked fine. Switching it to roller shutter mode caused it to only show sensors and no switches. image

edit: randomly started working after rebooting shelly and HA a couple of times