Variables in Yaml

Hi,

I’m totaly noobie with coding, so can someone help me with few things:

  1. how can I give state for sensor like “armed” or “disarmed”

  2. how to use boolean_senso as a variable? is there any easier way? I want to use it to show state in UI and also to control some stuff in yaml code

binary_sensor:
  alarm_activated:
    value_template: "{{states.input_boolean.alarm_activated.state == 'on'}}" 
    friendly_name: 'Alarm ACTIVATED'
	  
input_boolean: 
  alarm_activated:
    name: 'Alarm ACTIVATED'
	
automation:
  - alias: 'Alarm ACTIVATION'
    trigger:
      - platform: state
        entity_id: binary_sensor.sensor_1_0
        state: 'on'
    condition:
      - condition: state
        entity_id: alarm_control_panel.homealarm
        state: armed_away
    action:
      - service: alarm_control_panel.alarm_trigger
        entity_id: alarm_control_panel.homealarm
      - service: input_boolean.turn_on
        entity_id: input_boolean.alarm_activated

You can do this with a template sensor. Here’s an example:

acurite_wx:
  value_template: "{% if is_state('device_tracker.acurite', 'home') %}transmitting{% else %}down{% endif %}"
ex3700:
  value_template: "{% if is_state('device_tracker.ex3700fiosrouterhome', 'home') %}TX/RX Up{% else %}down{% endif %}"

Then in your groups, use the templated sensors name instead of the original sensor.

Thanks a lot!

Can you advice me how can I add a new sensor and how can I change that sensor state in “action” step in my example?

You can’t set a sensor state in an action.

~Cheers

1 Like