StyraHem / ShellyForHASS

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

[BUG] Shelly 'Config' / 'Setting' changes makes all Shelly devices unavailable #639

Open dannyyy opened 2 years ago

dannyyy commented 2 years ago

Environment

Describe the bug

  1. As soon as one of the checkboxes has been clicked - either on the 'Config' or 'Setting' page - after the next restart all Shelly devices appear as unavailable. image

  2. As soon as for the first time a checkbox has been clicked on 'Setting' page, all the preselected checkboxes gets unchecked Before (after a clean install / upgrade): image After (one click on any checkbox): image

Steps to Reproduce

  1. Navigate to 'Shelly' on the side nav
  2. Click any checkbox on the 'Config' or 'Setting' page
  3. Restart HA
  4. Every Shelly device / entity is unavailable. Can be checked under 'Developer Tools' / 'Configuration -> Devices' / 'Lovelace UI'

Reinstalling the Shelly integration has no effect. Since the last configuration state is persisted in core.config_entries. To getting back a working state, the entries within "data": { ... } and "options": { ... } must be cleaned manually. Dont' forget to restart HA.

Expected behavior

  1. Changes get reflected either after changing the 'Config' / 'Setting' or after a restart of HA. Shelly devices must be available after restart.

  2. Changing any of the checkboxes on the fresh 'Setting' page must not uncheck all the default settings.

Screenshots

Has been provided above.

Traceback/Error logs

No warnings or errors will be logged!

Home Assistant attempting to restart.
Restarting Home Assistant
2021-12-30 18:24:18 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-12-30 18:24:18 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration shelly which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-12-30 18:24:18 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration helios which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-12-30 18:24:18 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration ics which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-12-30 18:24:18 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration easycontrols which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-12-30 18:24:19 WARNING (MainThread) [homeassistant.components.lovelace] Resources need to be specified in your configuration.yaml. Please see the docs

Additional context

fredster1979 commented 2 years ago

I had a very similar issue. Once, I clicked something in the settings, you mentioned previously. My entries in configuration.yaml were ignored (shelly username and password for resticted login). I lost access to my shelly devices. Only after I added my username and password via configuration tab into core.config_entries I had access again. I don't know how to revert it. The behaviour I expected would be that configuration.yaml and core.config_entries complement each other. Or receive an error message if conflicting.

mbrihed commented 2 years ago

I have the same issue. I made a change in my config and now lost all shelly devices.

Klench commented 2 years ago

I have the same issue.

nlincke commented 2 years ago

Same on my side. Deleting and recreating the integration solves the problem. I just hide the config section.

hakana commented 2 years ago

Can someone check what is changed in the configuration that causes it to stop working? The configuration is stored under storage in the HA folder.

DamianosS commented 2 years ago

I've noticed that only the Shelly 1 go unavailable. Shelly Dimmer 2 or Shelly PM 2.5 will stay available. Is there a way to get the Shellys back (besides removing the integration)?

DamianosS commented 2 years ago

Can someone check what is changed in the configuration that causes it to stop working? The configuration is stored under storage in the HA folder.

Not sure. However, here's the record from core.config_entries:

       {
                "entry_id": "30dafa30ed396e6f4b5903ef1dd411d8",
                "version": 1,
                "domain": "shelly",
                "title": "configuration.yaml",
                "data": {},
                **_"options": {
                    "sensors": [
                        "click_type"
                    ]
                },_**
                "pref_disable_new_entities": false,
                "pref_disable_polling": false,
                "source": "import",
                "unique_id": null,
                "disabled_by": null
            },

I believe the highlighted part must be the changed portion, because I clicked the "sensors: click_type" checkbox.

DamianosS commented 2 years ago

Workaround: I've stopped HA, changed the "options" entry to "options": {}, and restarted HA.

Seems that everything is fine.

LCerebo commented 2 years ago

Workaround: I've stopped HA, changed the "options" entry to "options": {}, and restarted HA.

Seems that everything is fine.

Thanks a lot, this saved me a lot of troubles and a big headache!

DamianosS commented 2 years ago

Workaround: I've stopped HA, changed the "options" entry to "options": {}, and restarted HA. Seems that everything is fine.

Thanks a lot, this saved me a lot of troubles and a big headache!

Sure. However, @hakana, it would be great if this could be fixed! 😉

Stephan1908 commented 2 years ago

I no longer see switches from 2.5 and no lights from RGBW. In my core.config_entries it looks like this:

        {
            "entry_id": "a3caa9f916954578b4e2d1c3c74edf85",
            "version": 1,
            "domain": "shelly",
            "title": "configuration.yaml",
            "data": {
                "id_prefix": "shelly"
            },
            "options": {
                "mdns": true,
                "version": false,
                "upgrade_switch": true,
                "upgrade_beta_switch": false,
                "igmp_fix": false,
                "host_ip": "xxx.xxx.xxx.xxx",
                "mqtt_port": 1883,
                "additional_information": true,
                "scan_interval": 60,
                "unavailable_after_sec": 90,
                "username": "",
                "password": "",
                "cloud_auth_key": "",
                "tmpl_name": "",
                "cloud_server": "",
                "mqtt_server_host": "xxx.xxx.xxx.xxx",
                "mqtt_server_port": 1883,
                "mqtt_server_username": "xxx",
                "mqtt_server_password": "xxx",
                "attributes": [
                    "latest_beta_fw_version",
                    "ppm",
                    "total_work_time",
                    "battery",
                    "firmware_version",
                    "has_firmware_update",
                    "over_power",
                    "shelly_id",
                    "current_consumption",
                    "click_type",
                    "ip_address",
                    "rssi_level",
                    "total_returned",
                    "tilt",
                    "illuminance",
                    "vibration",
                    "device_temp",
                    "over_temp",
                    "ssid",
                    "total_consumption",
                    "shelly_type",
                    "rssi",
                    "uptime",
                    "switch",
                    "click_count",
                    "power_factor",
                    "humidity",
                    "voltage",
                    "sensor",
                    "mqtt_connected",
                    "current",
                    "latest_fw_version",
                    "temperature",
                    "cloud_status"
                ],
                "sensors": [
                    "rssi",
                    "rssi_level",
                    "uptime",
                    "over_power",
                    "current_consumption",
                    "total_consumption",
                    "total_returned",
                    "device_temp",
                    "over_temp",
                    "cloud_status",
                    "mqtt_connected",
                    "battery",
                    "voltage",
                    "power_factor",
                    "current",
                    "switch",
                    "click_type",
                    "tilt",
                    "vibration",
                    "temperature",
                    "humidity",
                    "illuminance",
                    "ppm",
                    "total_work_time"
                ]
            },
            "pref_disable_new_entities": false,
            "pref_disable_polling": false,
            "source": "import",
            "unique_id": null,
            "disabled_by": null
        },

Is there an error here?

Nenodema commented 2 years ago

Same issue here, after a restart / reboot of HA, I need to restart the Shelly device in order to get it "up and running" within HA.

dannyyy commented 1 year ago

I added today three Shelly RGBW2. Within the HA configuration, I extended my list of discover_by_ip with the three new devices. But no chance, even after several restarts, none of the three Shelly gets recognized and listed as device in HA.

Then I started checking the core.config_entries file and the new IPs weren't listed in there. After manually adding them to the discover_by_ip section, the three devices popped up and were available to integrate.

It's now a year ago and the Shelly integration is still partially broken. I'm on HA 2022.12 I really appreciate if this could be fixed asap.