Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95295

More elegant way for triggering switch with an input_boolean?

$
0
0

@ursus_polaris wrote:

Hi.

I’ve started to setup my home automation with home assistant and I’m amazed by the maturity of the project and the available integrations. Great job!

For my question:

I’m changing via some buttons the state of an input_boolean (via REST-call) and have an automation working that turns a switch on and off, according to the state of this input_boolean:

- id: itb100_to_sonoff_1
  alias: "IT-B-100 to sonoff mapper on"
  initial_state: on
  trigger:
  - platform: state
    entity_id: input_boolean.intertechno_button_it_b_100_left
    to: 'on'
  action:
    - service: switch.turn_on
      entity_id: switch.sonoff

    
- id: itb100_to_sonoff_2
  alias: "IT-B-100 to sonoff mapper off"
  initial_state: on
  trigger:
  - platform: state
    entity_id: input_boolean.intertechno_button_it_b_100_left
    to: 'off'
  action:
    - service: switch.turn_off
      entity_id: switch.sonoff
      

The reason I’m doing it a bit complicated is to have the ability to configure the whole house this way through HA - which is why I’m using it.

The code is working great - but I was wondering, if there isn’t a way to do the same with less code - meaning, if I can’t take the state of the ‘input_boolean’ as the new value of the switch, as this would result in about half the code… .

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95295

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>