Heaters Turn On / Off based on voltage and Grid input

I am trying to have my heaters working only when I have excess solar power

I want them Turning on only when their is Grid power and when Grid input is below 100w

I want them to Turn off when their is no Grid Voltage 200 - 300V and when Grid input is over 100w

am I missing something that is stopping it watching the power states
I can flip the grid connection off and its still running the heater from battery
same when I turn on the device it stays on even when its drawing over 200w

alias: Barra Heaters Off
description: 'Sonoff Bara Heaters '
trigger:
  - type: power
    platform: device
    device_id: 27cb64ba41eadc07fe39d6c5d9157002
    entity_id: sensor.stairs_inverter_power
    domain: sensor
    above: 100
condition: []
action:
  - type: turn_off
    device_id: 353fb2d011f47ed4bccd98cc316e40ab
    entity_id: switch.sonoff_1000f0cce5
    domain: switch
mode: single
alias: Barra Heaters On
description: ''
trigger:
  - type: power
    platform: device
    device_id: 27cb64ba41eadc07fe39d6c5d9157002
    entity_id: sensor.stairs_inverter_power
    domain: sensor
    below: 100
condition:
  - type: is_voltage
    condition: device
    device_id: 27cb64ba41eadc07fe39d6c5d9157002
    entity_id: sensor.stairs_inverter_voltage
    domain: sensor
    above: 200
    below: 300
action:
  - type: turn_on
    device_id: 353fb2d011f47ed4bccd98cc316e40ab
    entity_id: switch.sonoff_1000f0cce5
    domain: switch
mode: single

I also have to do something about when the meross’s are “Unavailable” because wifi is crap …

It triggers only at the moment the power value crosses the threshold of 100. In other words, at the moment when it increases from below 100 to above 100.

thanks , how can I have it trigger if the value is already at 180 ?

and for it to turn off the heater when reading becomes unavailable ?

trigger:
- platform: template
    value_template: >-
      {{ trigger.from_state.state if ['Unavailable', 'unavailable', 'unknown']
      }}

the main load with pumps and compressor average 180watts ,
as the sun comes up and battery gets charged this drops to 0

system is set up to allow 2 days worth of battery backup so battery bank is kept above 90% charge at all times and runs from grid when battery voltage drops

Use a State Trigger with a Numeric State Condition.

platform: state
entity_id: sensor.stairs_inverter_power
from: '100'

or

platform: numeric_state
entity_id: sensor.stairs_inverter_power
above: '100'

and would this work to turn off if device becomes Unavailable , ultimately what would happen if grid was down anyhow

 - platform: state
    entity_id: sensor.stairs_inverter_voltage
    to: Unavailable

Neither. Why have you chosen attribute: unit_of_measurement? It doesn’t contain the sensor’s power value. It simply contains a string like “W” or “kW” indicating the sensor’s unit of measurement.