esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
420 stars 26 forks source link

Allow switch as source for copy binary sensor #2957

Closed antonio-fiol closed 4 days ago

antonio-fiol commented 5 days ago

Describe the problem you have/What new integration you would like

Allow switch as source for copy binary sensor

Please describe your use case for this integration and alternatives you've tried:

  1. To allow exposing the state of an internal switch to HA, without allowing actions on it.
  2. To allow filtering of the switch state as if it were a binary sensor, for use inside ESPHome.

The alternative is creating a template binary sensor, either with a lambda to copy the state of the switch, or with events on the switch to publish its state to the binary sensor. But the code for event-based is cleaner than the copy pattern, and the lambda would execute on every loop.

Additional context