Trigger failing

I’m sure this must be the most common topic but here goes.
I’ve just created a automation to switch on/off a towel rail heater using a Shelly plus1 relay, this dependent on the percentage charge of my Tesla powerwall battery.
I have created two threshold sensors that are in an on or off state, one when the battery is above 99% and one when the battery is below 97%. I can see these are working correctly changing from on/off and visa versa. I have used these in two automations one to switch on the towel rail and one to switch it off.
I have checked the states that should cause the trigger are working, I’ve checked the action is working correctly manually but for some reason the automation will not trigger. This is the automation that should turn the towelrail on when the battery is above 99% (the threashold sensor will then go from off to on), can anyone see an issue?

id: '1650383854973'
alias: Towel Rail A - ON
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.powerwall_100
    attribute: sensor_value
    from: 'off'
    to: 'on'
condition:
  - condition: time
    after: '09:00:00'
    before: '17:00:00'
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
action:
  - type: turn_on
    device_id: 179101863ebb25a30f532f04b8b3b99a
    entity_id: switch.shellyplus1pm_7c87ce65cfa0_switch_0
    domain: switch
mode: single
    attribute: sensor_value

That’s your problem

The trigger is waiting for that attribute to go from off to on.

That’s never going to happen

Remove that line

I don’t understand the state of the sensor does change from off to on…

Powerwall 100%

5 minutes ago

Off

History

entity_id=binary_sensor.powerwall_100&start_date=2022-04-20T23:00:00.000Z)

Logbook

entity_id=binary_sensor.powerwall_100&start_date=2022-04-20T23:00:00.000Z)

#### 22 April 2022

Turned off

18:45:54 - 4 minutes ago

Turned on

14:10:12 - 5 hours ago

Turned on

13:09:18 - 6 hours ago

Attributes

Entity ID

sensor.powerwall_charge

Hysteresis

0

Lower

—

Position

below

Sensor value

98

Type

upper

Upper

99

i removed those lines… will test again

Thanks that worked.

Yes, the state changes, and you configured the trigger to look not at the state, but at the attribute sensor_value.