How to create a state machine with HA automation

i thing i got this

value_template: {{ state_attr(‘switch.shelly_shsw_pm_76bed9’, ‘consumption’) }}

This is what I have for my washing machine. As you can see, the ‘current’ is an attribute of the entity.

So you need to code for the attribute of your shelly unless you possibly have an independent entity purely for the ‘current’ or ‘power’ value that you can utilise directly without having to extract the attribute.

Suggests you can use this directly without the need for a template at all. Just use this entity_id in the automation and completely forget about using a template sensor.

I am trying to use your example to create an alarm state machine. But I am new to HA and tripping all over it. Can you take a look at my shortened example?

input_select:
  myalarm_state:
    name: Alarm is
    icon: mdi:alarm-bell
    options:
      - "disarmed"
      - armed
      - triggered
    initial: "disarmed"
alias: my_alarm
description: automation to act if armed and door opens
trigger:
  - type: opened
    platform: device
    device_id: 36bb36a75308b28f2d2591bb9e8f2661
    entity_id: binary_sensor.back_sliding_door_state
    domain: binary_sensor
condition:
  - condition: and
    conditions: [myalarm_state.options==armed]
action: 
  - service: notify.notify
    data:
      message: Alarm Triggered
mode: single

I stuck some c psuedo in the conditions line because I am unsure what to do. This code is in a packages yaml file but I am unsure how to use it. Can you elaborate on that also? What I ultimately want to do is add a card in the ui that allows me to arm and disarm the automation (or whatever) so that I can turn notifications on/off and then add a timer that will trigger a siren if I do not disarm in time. TIA!!

Perhaps you should use an alarm integration to start with.

As with what Nick has said, I suggest you use an Alarm integration. My advice is is use ‘Alarmo’. You’ll find it as a custom Integration in HACS.