Anyone used Mi thermometer sensor values to trigger an action

Has anyone who has got these sensors with custom firmware had any luck using the resulting sensor entity state vales (humidity, temperature), in an action.

It seems whatever I do like test if the value of sensor.sensor01Humidity has gone over 65 the action never gets triggered.

Yet if I use another numeric value like my phone battery level I can perform any action I want.

Has anyone successfully used these sensors to fire an action like turn of plug if humidity goes over 65%.

I can play around with the values in Dev tools template and use code to do different things and this works I just can’t seem to get an automation to work using these values in a numeric_value.

Any ideas would be appreciated


Go to Developer Tools —> States (tab) —> Type your sensor entity_id —> Copy the state as well as the state attributes here.

Next, post the automation code that you have tried (but did not work).

Hi there,

Entity: sensor.atc001_humidity
State: 65.16
state_class: measurement
unit_of_measurement: ‘%’
friendly_name: White Widow Jar 01 RH
device_class: humidity

This is what I’ve been playing with in dev tools

‘{{ states('sensor.atc001_humidity')  | round(0) }}

{% for humidity in ['sensor.atc001_humidity', 'sensor.atc002_humidity', 'sensor.atc003_humidity'
   , 'sensor.atc004_humidity' , 'sensor.atc005_humidity' , 'sensor.atc006_humidity'] %}
        {% if states(humidity) | float > 60%}
            {{state_attr(humidity, "friendly_name")}} ({{states(humidity)| round(0) }}%);
        {% endif %}
    {% endfor %}
{% if states('sensor.atc001_humidity') | float > 65 %}
    Time to burp Jar 01
{% else %}
    Below 65% Humidity
{% endif %}
  - platform: template
      unit_of_measurement: '%'
       device_class: humidity
       friendly_name:  ‘Jar 01 Humidity'
       value_template: "{{ states('sensor.atc001_humidity')  | round(0) }}"
       device_class: humidity
       unit_of_measurement: '%'
       friendly_name: 'Jar 02 Humidity'
       value_template: "{{ states('sensor.atc002_humidity')  | round(0) }}"

{% if states('sensor.atc001_humidity' or 'sensor.atc002_humidity' or 'sensor.atc003_humidity'
       or 'sensor.atc004_humidity' or 'sensor.atc005_humidity' or 'sensor.atc006_humidity') 
     | float >= 65%}
{% else %}
{% endif %}’

Results as expected all works great, however when the same values are used in an automation I get no response.

‘alias: Burp Jars
description: Notify when curing jar’s need to be refreshed
  - platform: numeric_state
      - sensor.atc001_humidity
      - sensor.atc002_humidity
      - sensor.atc003_humidity
      - sensor.atc004_humidity
      - sensor.atc005_humidity
      - sensor.atc006_humidity
    attribute: unit_of_measurement
    above: '65'
    id: humidity-alert
condition: []
  - service: notify.notify
      title: Over 65% Humidity Alert!
      message: >-
        {% for humidity in ['sensor.atc001_humidity', 'sensor.atc002_humidity',
        'sensor.atc003_humidity' , 'sensor.atc004_humidity' ,
        'sensor.atc005_humidity' , 'sensor.atc006_humidity'] %} {% if
        states(humidity) | float > 65%} {{state_attr(humidity,
        "friendly_name")}} ({{states(humidity)| round(0) }}%); {% endif %} {%
        endfor %}
mode: single‘

Try removing the attributes in the trigger-

  - platform: numeric_state
    entity_id: sensor.atc001_humidity
    above: '65'

Note that numeric_state only triggers when the value crosses your threshold.

I’m not sure I’m with you on removing the trigger attributes?

I’ve also tried crossing the value threshold (by setting the above value to 70% then breathing on the thermometer to raise the humidity, still nothing.

I’m beginning to think that you cannot use the values from these sensors to create any triggers.

Everything else works?

Because it’s the state of the entity, not state attributes.

Oh I get you I just added the numeric_state attribute in an attempt to get it to do something at least, I have removed it again now and it still doesn’t do anything.

As mentioned I can take the state of any other entity that has a numeric_state attribute and this automation will work it just doesn’t wanna work using the sensor entity state.

I cannot work out what’s going on am quite new to this although I’ve already got the code syntax this device however eludes me.

That’s why I was asking if anyone else has used one of these to trigger an action.

Most tutorials I see on these are for getting the values without having to log into the device.

Set the threshold above: 65.
Next, go to Developer Tools —> States (tab) —> Type your entity sensor name —> Change the state to 60 —> Set States —> Change the state again to 70 —> Set States

If it doesn’t trigger, check your automation trace-

Yep that worked I got a notification, so my automation does work it’s just the values seem to have to change so drastically before the automation is triggered is there anyway to detect subtle changes. Or at least make the listener more sensitive to change.

Edit: by the way thanks for the debugging tips dude.

Remember it has to cross the threshold.

That’s the thing the values had and have crossed the threshold previously and the automation never fired.

It has only just started working since I did what you said and set the state to above and below my target for one of the sensors to trigger the automation and wake up the listener.

Before it did nothing, so my next question is do you have to wake up the listener every time you create a new automation?

What on earth do you mean “wake up the listtener”

The automation is triggered when the sensor goes from, say, 64 to, say 66.

The service that listens for the change, anyway it’s working now and I’ll just set the state for any more I do to make sure the service is active.

Thanks very much for all your help, much appreciated.