8000 Shelly button issue with automations when used as trigger · Issue #48837 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Shelly button issue with automations when used as trigger #48837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
LZ7AA opened this issue Apr 8, 2021 · 2 comments · Fixed by #48974
Closed

Shelly button issue with automations when used as trigger #48837

LZ7AA opened this issue Apr 8, 2021 · 2 comments · Fixed by #48974
Assignees

Comments

@LZ7AA
Copy link
LZ7AA commented Apr 8, 2021

The problem

When Shelly button is used as trigger in automation and HA is freshly restarted the automation is not triggered because the device_trigger.py throws an exception. Creating a new automation or editing an existing one with shelly button trigger is not possible because the shelly device trigger is unavailable. The "trigger type" and "device" are available, but the "trigger" is not (S, SS, SSS, L). Home Assistant server restart is not possible as the check configuration detects an error "Unexpected error calling config validator: 'NoneType' object is not iterable".
This error state lasts until a button is pressed. Once any shelly button is pressed the trigger script initializes/passes and button triggers become available. Unfortunately this first press gets missed by the automations.
This behavior is caused by the Shelly button being in sleep mode (unavailable) until pressed.

What is version of Home Assistant Core has the issue?

core-2021.3.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Shelly

Link to integration documentation on our website

https://www.home-assistant.io/integrations/shelly

Example YAML snippet

1. add Shelly integration
2. add Button device (the device is on USB power)
3. create some automation using the shelly button device
### Automation sample ###
platform: device
device_id: 9f0f19857071c75042b78f0dec1d6b62
domain: shelly
type: long
subtype: button

4. disconnect the shelly button from the USB power, wait for it to go to sleep.
5. restart HA
6. go to the automation and edit it - the shelly button trigger is unavailable
7. go to Configuration / Server Controls / Check Configuration - results in error
8. try restarting the HA server - not possible because of the config check failing.
9. Press the button of the sleeping shelly device
10. Now all works correctly until HA restart.

Anything in the logs that might be useful for us?

Logger: homeassistant.components.websocket_api.http.connection
Source: components/shelly/device_trigger.py:71
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 19:32:28 (1 occurrences)
Last logged: 19:32:28

[2812764992] Error handling message: Unknown error
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 18, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/device_automation/__init__.py", line 187, in with_error_handling
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/device_automation/__init__.py", line 237, in websocket_device_automation_list_triggers
    triggers = await _async_get_device_automations(hass, "trigger", device_id)
  File "/usr/src/homeassistant/homeassistant/components/device_automation/__init__.py", line 133, in _async_get_device_automations
    device_automations = await asyncio.gather(
  File "/usr/src/homeassistant/homeassistant/components/device_automation/__init__.py", line 108, in _async_get_device_automations_from_domain
    return await getattr(platform, function_name)(hass, device_id)
  File "/usr/src/homeassistant/homeassistant/components/shelly/device_trigger.py", line 71, in async_get_triggers
    for block in wrapper.device.blocks:
TypeError: 'NoneType' object is not iterable

Logger: homeassistant.helpers.check_config
Source: components/shelly/device_trigger.py:53
First occurred: 12:48:01 (1 occurrences)
Last logged: 12:48:01

Unexpected error validating config
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/check_config.py", line 147, in async_check_ha_config_file
await config_validator.async_validate_config( # type: ignore
File "/usr/src/homeassistant/homeassistant/components/automation/config.py", line 103, in async_validate_config
await asyncio.gather(
File "/usr/src/homeassistant/homeassistant/components/automation/config.py", line 85, in _try_async_validate_config_item
config = await async_validate_config_item(hass, config, full_config)
File "/usr/src/homeassistant/homeassistant/components/automation/config.py", line 63, in async_validate_config_item
config[CONF_TRIGGER] = await async_validate_trigger_config(
File "/usr/src/homeassistant/homeassistant/helpers/trigger.py", line 49, in async_validate_trigger_config
conf = await platform.async_validate_trigger_config(hass, conf)
File "/usr/src/homeassistant/homeassistant/components/device_automation/trigger.py", line 21, in async_validate_trigger_config
return await getattr(platform, "async_validate_trigger_config")(hass, config)
File "/usr/src/homeassistant/homeassistant/components/shelly/device_trigger.py", line 53, in async_validate_trigger_config
for block in wrapper.device.blocks:
TypeError: 'NoneType' object is not iterable

@thecode
Copy link
Member
thecode commented Apr 8, 2021

Thanks @LZ7AA for the detailed reproducing steps, I understand what is causing the issue, fix for it is simple, I will try to make it ready for the next hotfix.

@LZ7AA
Copy link
Author
LZ7AA commented Apr 14, 2021

Thank you for the prompt reaction. Unfortunately the issue with the Shelly sleeping button partly fixed.
The automation edit in UI is OK and configuration validation passes now, but the first ever trigger is missed. The automation, which uses button trigger misses the first press after server restart. Second press successfully triggers the automation.
= core-2021.4.4
= nothing in the logs for the first trigger/press
I will open a new issue for this.

@github-actions github-actions bot locked and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@balloob 2DA6 @thecode @LZ7AA
0