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

binary_sensor filters templatable delays #5029

Merged
merged 4 commits into from Jul 4, 2023

Conversation

dudanov
Copy link
Contributor

@dudanov dudanov commented Jun 30, 2023

What does this implement/fix?

  1. Binary sensors delay filters can be configured with template parameters similar to the delay action:
binary_sensor:
  - platform: ...
    filters:
      - delayed_on_off: !lambda "return id(drying_delay).state * 1000;"
      - delayed_on: !lambda "return 1000;"
      - delayed_off: !lambda "return 2000;"
  1. delayed_on_off filter can take the turn-on and turn-off delay times as separate parameters time_on and time_off if required, which is simply irreplaceable for many automations (it is impossible to replace it with a chain of delayed_on and delayed_off). Of course, backward compatibility is preserved. Moreover, the old one-line notation is shorter and it is better to use it if the delays are the same.
binary_sensor:
  - platform: ...
    filters:
      - delayed_on_off:
          time_on: 2min
          time_off: !lambda "return id(drying_delay).state * 1000;"

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#3034

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@probot-esphome
Copy link

Hey there @esphome/core, mind taking a look at this pull request as it has been labeled with an integration (binary_sensor) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

Copy link
Member

@jesserockz jesserockz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@jesserockz jesserockz merged commit 5b21765 into esphome:dev Jul 4, 2023
25 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jul 5, 2023
@dudanov dudanov deleted the bsensors-delay-lambdas-300623 branch July 27, 2023 06:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants