Automation - Sonoff iFan03 Cannot trigger

I am puzzled why I cannot get this automation to trigger.

- id: '1621026002356'
  alias: Master Bedroom Fan Turn-On
  description: Turn on MB Fab when kitchen temp above 25C
  trigger:
  - platform: numeric_state
    entity_id: sensor.indoor_temperature
    above: '25'
  condition: []
  action:
  - service: fan.turn_on
    target:
      entity_id: fan.sonoff_1000f6e1ca
    data:
      percentage: 33
  mode: single

When this one does

- id: '1621026209400'
  alias: Master Bedroom Fan Turn-Off
  description: Turn OFF MB Fab when kitchen temp below 25C
  trigger:
  - platform: numeric_state
    entity_id: sensor.indoor_temperature
    below: '25'
  condition:
  - condition: and
    conditions:
    - condition: state
      entity_id: fan.sonoff_1000f6e1ca
      state: 'on'
  action:
  - service: fan.turn_off
    target:
      entity_id: fan.sonoff_1000f6e1ca
  mode: single

Been scratching my head for time time
Any suggestions gratefully received

What is the config for the iFan03? Do you have it configured to use percentages?

Hi
The config I have used is

This uses HACS and I have installed it through HACS.
Using this UI card
image
I can control

  • on/off
  • Speed

I hope that answers your question.

Just to see …
I changed the trigger to a Time (eg trigger at 10:00:00) and it triggered.

This the trace for the Turn Off automation which works


image

It doesn’t even trigger at 26°C?
Maybe try with ‘25.0’ to coerce to a float value?

try removing the quotes around the number:

trigger:
  - platform: numeric_state
    entity_id: sensor.indoor_temperature
    below: 25

Thanks to those who replied.
The single quotes were inserted by HA not me in the Automation’s form so I am assuming they are correct and they are also in the Turn Off.

I have made a change that I am testing today.
I noted that the main difference between the “Turn Off” to the “Turn On” was the conditional AND so included that just to test.

- id: '1621026002356'
  alias: Master Bedroom Fan Turn-On
  description: Turn on MB Fab when kitchen temp above 25C
  trigger:
  - platform: numeric_state
    above: '25'
    for: 00:01:00
    entity_id: sensor.indoor_temperature
  condition:
  - condition: and
    conditions:
    - condition: state
      entity_id: fan.sonoff_1000f6e1ca
      state: 'off'
  action:
  - service: fan.turn_on
    target:
      entity_id: fan.sonoff_1000f6e1ca
    data:
      percentage: 33

If this change works then I will be happy but still confused.
If it does not then I will then try the 25.0 to test that suggestion.
here’s hoping something does.

just so I don’t have to wait until mid morning I have changed the Turn On temp trigger to 21 rather than 25. It should make no difference in logical terms, just quicker to test.

Well the inclusion of the AND conditioned worked.

Trace below

I will stop it now and change temperature back to 25C and see if it re-triggers.

I can now report that the Automation did trigger at 25C. I cannot explain why adding the condition made it work but it did.
If someone can enlighten me then I would be grateful for the information.
I will leave it on the bench until my Hand Held Digital Tacho turns up so I can check RPM of the three speeds.
I want to be sure that the capacitors are working as they should.

Google Assistant works but is a bit tricky.
In order for GA to get it straight you must leave the word FAN out of the naming of the Light or in other words you must name it
“Master Bedroom Light” rather than “Master Bedroom Fan Light”
If you don’t and you ask GA if the MB Fan is on it will tell you the Light Status rather than the FAN.
Yeah GA is a bit dumb that way, maybe in the future…

I can’t.

it shouldn’t have made any difference at all without the condition in there.

I know you said that it made a difference but I will still say there had to be some other reason that it works with it but not without it.

Well I might have found a possible explanation.
Today I decided to move the iFan03 off my test bench to it’s real location on the Master Bedroom Ceiling Fan.
The automation had triggered for the day.
However when I connected the iFan03 to the Fan and switched the circuit breaker back on this is what I noticed.

Prior to the install I had disabled the turn on & off Automation’s.

After power reapplied
I tested the functionality with the 433MHz remote.
Fan speed 1, Fan Speed 2, Fan Speed 3 and stop fan. All Good here.
Light not used.
I then tested WiFi functionality with HA doing the same as above.

I also tested Google Assistant and it worked as it did on the bench.

I now re-enabled the automations for on/off.

Now it did not trigger!

I wonder if the single mode has anything to do with it?

I am not sure I understand this
What are your thoughts?

The “single” mode just means that the automation can only run one thread at a time. I.E. if the automation gets triggered then while the automation actions are still running if another trigger occurs during that time the second trigger is ignored.

Usually this would only have any noticeable effect for automation actions that have built-in delays.

Since your automation is literally a milliseconds long action then the single mode wouldn’t have any impact.

And, TBH, you wouldn’t want this automation to run in any other mode.

You are sure that the automations states are indeed ‘on’ in the dev tools states page?

Also, I’ve seen some weirdness before using numeric state triggers. So much so that I tend to avoid them and just use template triggers instead.

You could try that and leave out the condition to see if it triggers that way.

OH, also, what size caps did you end up using and how were the speeds?

Thank you for explaining that. It was what I thought but was never sure.

Yes The Automation state is “On” in dev tools.
Templates are something that are foreign to me. I would like to learn them but never really found something that I could understand enough to try them.
Could you give me a “For Example” on this situation please. Once I get an idea in a practical sense I can usually learn from that. I would appreciate that.

I would like to try the templates and then remove the condition if possible.

Capacitors?
I did not have to adjust them as I am in Australia which uses 240V mains so the fitted capacitors were OK for me.

I also was using a ceiling fan that is 38 years old (original when we built the house) and it’s controller box was a transformer with a wafer switch, 5 speed settings and an off position. No Capacitors.

The fan motor was perfectly functional incl. bearings so did not see the need for a new fan. Maybe someday?
The controller was a bit sad due to UV effects on the plastic so hence the targeting.
I have even got Google Assistant to change speeds from Low to medium to high using voice commands on a Google Nest Hub Gen 2.

this:

trigger:
  - platform: numeric_state
    above: '25'
    for: 00:01:00
    entity_id: sensor.indoor_temperature

can be converted to this:

trigger:
  - platform: template
    value_template: "{{ states('sensor.indoor_temperature') | int > 25 }}"
    for: "00:01:00"

here is the doc section for that code:

and templating in general:

Thank you for doing that.
I have been at the Physio…

I changed the trigger temp to 26 though.

I did this


Which is

- id: '1621026002356'
  alias: Master Bedroom Fan Turn-On
  description: Turn on MB Fab when kitchen temp above 26C
  trigger:
  - platform: template
    value_template: "{{ states('sensor.indoor_temperature') | int > 26 }}"
    for: "00:01:00"
  condition:
  - condition: and
    conditions:
    - condition: state
      entity_id: fan.sonoff_1000f6e1ca
      state: 'off'
  action:
  - service: fan.turn_on
    target:
      entity_id: fan.sonoff_1000f6e1ca
    data:
      percentage: 33
  mode: single

It still does not trigger and current indoor temp is 27.1
Beats me for the moment.

if you go to the services section and select automation.trigger and that automation entity_id then click “call service” does the fan turn on?

then check the “skip conditions” box and turn the toggle to the right off then run the service again. Does the fan turn on?

First Test
select automation.trigger and that automation entity_id then click “call service” does the fan turn on?
Yes
“skip conditions” box and turn the toggle to the right off then run the service again. Does the fan turn on?
Yes

OK, I really don’t know what that means?

Some minutes later
BTW as the indoor temp is now 25.8 the turn off automation triggered

That just verifies that the issue is indeed the trigger.

Also, just to verify…you are seeing the temperature go below 26.0 and then above 26.0 and the fan does not turn on?

was that not expected? what is the fan turn off setpoint?

OK. Thank you for your patience.

I am not quite sure what you mean
you are seeing the temperature go below 26.0 and then above 26.0 and the fan does not turn on?

What I am seeing is that as the indoor temperature rises in the morning and goes above 26 for 1 minute the turn on Automation triggers and turns the fan on.
As the temperature goes down in the evening below 26 for 1 minute the turn off automation triggers.

However if, for whatever reason, I manually turn off the fan by 433MHz or in HA; then if the temperature is > 26 the turn on automation does not trigger. I am wondering if it should? Is this what it’s supposed to do and I am chasing my tail?

Yes the Turnoff was expected.
I wanted to have the fan turn on >26 and turn off < 26
26 is just a number I picked for testing. I will fine tune that number as time goes on.
In summer I run and air conditioner in the room set at 25. This works more efficiently if the fan is running on low speed.

I hope that makes sense.