Binary sensor from

I have a Aqara sp-euc01 integrated with Z2MQTT.

I’m trying to create a binary sensor based on power consumption. If the power consumption is bigger than 10W, then the binary sensor is on; otherwise, it is off.

{{ states.sensor.test_sw_power }}
<template TemplateState(<state sensor.test_sw_power=2.66; state_class=measurement, unit_of_measurement=W, device_class=power, friendly_name=Test SW Power @ 2024-07-26T09:40:17.360785+03:00>)>

How can I get the power value(2.66)?

{{ states('sensor.test_sw_power') | float(0) > 10 }}

You can test it in developer tools.

If you want to switch devices based on it, you can also consider a threshold sensor. It has a hysteresis setting, which helps you to say: it must be somewhat over 10 to turn on, or somewhat below 10 to turn off. Having such a hysteresis helps prevent constant on/off switching when the value fluctuates around the limit. You can create one in the helpers section.

Bedtime reading:

1 Like