Skip to content
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

Automations being saved with below value higher than above value causing trigger setup to fail #9937

Closed
3 tasks done
deosrc opened this issue Sep 2, 2021 · 0 comments · Fixed by #9947
Closed
3 tasks done
Labels
Bug Current Bug in UI - Extra Attention

Comments

@deosrc
Copy link

deosrc commented Sep 2, 2021

Checklist

  • I have updated to the latest available Home Assistant version.
  • I have cleared the cache of my browser.
  • I have tried a different browser to see if it is related to my browser.

Describe the issue you are experiencing

When editing an automation with a device trigger based on numeric state, the automation can be edited in a way that results in a "below" value above an "above" value. This will then successfully save but fail to configure the trigger resulting in the automation not running:

voluptuous.error.MultipleInvalid: A value can never be above 99.0 and below 0.0 at the same time. You probably want two different triggers.

The most common case of this is when only one of the properties is wanted (i.e. trigger when value is above 99). The only workaround at the moment seems to be editing the YAML manually as any change to the input field adds the property.

Describe the behavior you expected

  • When the below value is greater than the above value, validation should prevent the automation from saving and instead show the user an error message
  • When one of the below or above values is removed from the UI, this should also remove it from the YAML for saving

Steps to reproduce the issue

  1. Create a new automation and add a device trigger. Ensure the trigger is based on a numeric state (e.g. power)
  2. Edit the trigger so that the "above" value is set (e.g. 99). Move out of the input box and switch to YAML view. The value will be present and "below" should not be.
  3. Go back to the visual editor and change the "below" value to something higher (e.g. 101). Move out of the input box and switch to YAML view. Both values should now be present.
  4. Go back to the visual editor and remove the "below" value. Move out of the input box and switch to YAML view. Below will now read as 0. Since above is higher than below, this is an impossible state.
  5. Go back to the visual editor and save the automation. This will succeed but will create an error message in the logs.

There is also a related issue when editing an automation in that the input for an automation with no "below" value will default the UI to 0. This appears to only be cosmetic though and the property is not added to the YAML until the input field is edited.

What version of Home Assistant Core has the issue?

2021.9.0

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

Firefox 91.0.2

Which operating system are you using to run this browser?

Windows 10

State of relevant entities

No response

Problem-relevant frontend configuration

- type: battery_level
    platform: device
    device_id: aea6b16641e500c3e23c5b64a4848bdc
    entity_id: sensor.tablet_battery_level
    domain: sensor
    below: 0
    above: 99

Javascript errors shown in your browser console/inspector

No response

Additional information

Log message:

Logger: homeassistant.components.automation.home_tablet_battery_reporting
Source: components/sensor/device_trigger.py:161
Integration: Automation (documentation, issues)
First occurred: 1:41:30 PM (2 occurrences)
Last logged: 4:17:22 PM
Error setting up trigger Home - Tablet Battery Reporting

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
    return schema(data)
  File "/usr/src/homeassistant/homeassistant/components/homeassistant/triggers/numeric_state.py", line 39, in validate_above_below
    raise vol.Invalid(
voluptuous.error.Invalid: A value can never be above 99.0 and below 0.0 at the same time. You probably want two different triggers.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/device_automation/trigger.py", line 31, in async_attach_trigger
    return await platform.async_attach_trigger(hass, config, action, automation_info)
  File "/usr/src/homeassistant/homeassistant/components/sensor/device_trigger.py", line 161, in async_attach_trigger
    numeric_state_config = numeric_state_trigger.TRIGGER_SCHEMA(numeric_state_config)
  File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 218, in __call__
    return self._exec((Schema(val) for val in self.validators), v)
  File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 341, in _exec
    raise e if self.msg is None else AllInvalid(self.msg, path=path)
  File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 337, in _exec
    v = func(v)
  File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 276, in __call__
    raise er.MultipleInvalid([e])
voluptuous.error.MultipleInvalid: A value can never be above 99.0 and below 0.0 at the same time. You probably want two different triggers.
@deosrc deosrc added the Bug Current Bug in UI - Extra Attention label Sep 2, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Current Bug in UI - Extra Attention
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant