#Help with Automation not working

1 messages ยท Page 1 of 1 (latest)

mortal path
#

I cant post it as its too big can someone msg me so I can send the automation

rich moat
mortal path
#

Thanks!

mortal path
#

@rich moat

humble sorrel
#

What is the issue with automation?

#

I would suggest you to ditch the device_id and move to a nice entity_id setups.

mortal path
#

The issue is I sometimes have to manually run the reset automation for the night one to work

#

I did change everything to entity. That was an oops on my part

uneven umbra
#

What is the idea with the template condition to check for exactly 22:00:00?

And what are the automation traces showing? What is preventing the night automation?

mortal path
#

the ran today boolean isnt getting reset

uneven umbra
#

So my questions remain valid to answer ๐Ÿ™‚

mortal path
#

I had to check what I see is itโ€™s looking so it wonโ€™t run before 22:00:00 @uneven umbra

#

Also please tag me so I see it quicker

uneven umbra
#

@mortal path As starter of this thread, don't you just get a notification for every post?

But seems that dpaste isn't working so can't look at the whole yaml. But what I remember you had a check in it for exactly 22:00:00, which is nearly impossible to hit ๐Ÿ˜„

mortal path
#

Here it is again. The 22 is it only runs if its afterr 22:00

willow nebula
#

Something to try split the time condition into two separate conditions.

uneven umbra
#

In mean this:

          - condition: template
            value_template: "{{ now().strftime('%H:%M:%S') == '22:00:00' }}"

Very hard to hit exactly 22:00:00.

Where

          - condition: state
            entity_id: sensor.iphone_battery_state
            state: Charging

Is always true as that's the trigger ๐Ÿ˜„

But what does the trace of the "Reset iPhone Charging Flag" say? As it's a pretty straightforward automation...

placid geode
#

Yes, that was what I was typing as well, that whole and-condition doesn't make much sense to me

#

That conditions block of the first automation could just be

conditions:
  - condition: state
    entity_id: input_boolean.iphone_charging_ran_today
    state: "off"
  - condition: time
    after: "22:00:00"
    before: "09:00:00"
#

note that the time will be logged in microseconds, so 22:00:00.000001 is also after 22:00:00
It's virtually impossible to trigger on exactly 22:00:00.000000 which could maybe the the reason why you added it

mortal path
#

I donโ€™t understand that. I am sorry I am new to this

placid geode
#

We are saying that this part of your automation doesn't add any value.

      - condition: and
        conditions:
          - condition: template
            value_template: "{{ now().strftime('%H:%M:%S') == '22:00:00' }}"
          - condition: state
            entity_id: sensor.iphone_battery_state
            state: Charging

In the first condition you are checking if it's exactly 22:00:00, but that is already covered by the other condition
And if the second part you are checking if the battery state sensor is on Charging , but that is what you are triggering on, so you already know that that is the case

#

So your whole conditions section can simply be:

conditions:
  - condition: state
    entity_id: input_boolean.iphone_charging_ran_today
    state: "off"
  - condition: time
    after: "22:00:00"
    before: "09:00:00"
#

oh and you are turning the same lights on twice (light.stick and light.stick_2). First with only a brightness percentage, then also with a color temperature combined with the same brightness percentage

#

But all of this is not to fix your issue.
What could be the case is that you start charging your phone between 8:00 and 9:00 in the morning.
Your first automation checks on a time period between 22:00 and 9:00
Your second automation resets the boolean at 8:00

So when you charge your phone between 8:00 and 9:00, the first automation kicks in, and the second automation will not reset the boolean before 8:00 next day

#

so you might want to align those times

mortal path
#

Ok here is what I have

#

alias: iPhone Wireless Charging Triggered
description: Run once per night when iPhone starts charging
triggers:

  • entity_id:
    • sensor.iphone_battery_state
      to: Charging
      for:
      hours: 0
      minutes: 0
      seconds: 0
      trigger: state
      conditions:
  • condition: state
    entity_id: input_boolean.iphone_charging_ran_today
    state: "off"
  • condition: time
    after: "22:00:00"
    before: "09:00:00"
    actions:
  • target:
    entity_id:
    - switch.fan
    action: switch.turn_on
    data: {}
  • data:
    brightness_pct: 100
    target:
    entity_id:
    - light.stick_2
    - light.stick
    action: light.turn_on
  • action: light.turn_on
    metadata: {}
    data:
    brightness_pct: 100
    color_temp_kelvin: 2605
    target:
    entity_id:
    - light.floor_lamp_pro
    - light.living_room_lamp
    - light.stick_2
    - light.stick
    - light.living_room_overhead
    - light.living_room_overhead_2
  • target:
    entity_id: input_boolean.iphone_charging_ran_today
    action: input_boolean.turn_on
    data: {}
  • delay: "00:00:05"
  • target:
    entity_id:
    - light.living_room_lamp
    - light.floor_lamp_pro
    - light.led_magic_light
    - light.office_light
    - light.office_light_2
    - light.lamp
    - light.overhead_2
    - light.overhead
    - light.living_room_overhead
    - light.living_room_overhead_2
    - light.stick_2
    - light.stick
    action: light.turn_off
    data: {}
  • action: switch.turn_off
    data: {}
    target:
    entity_id: switch.roses
  • data:
    preset_mode: sleep
    target:
    entity_id:
    - fan.air_purifier
    - fan.core_400s
    action: fan.set_preset_mode
  • action: input_number.set_value
    metadata: {}
    data:
    value: 30
    target:
    entity_id: input_number.projector_off_minutes
    mode: single
#

The stick ones are two different smart bulbs on one lamp

placid geode
#

Please use code formatting

compact patrolBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

mortal path
placid geode
#

Okay, and does it work as expected with these automations?

mortal path
#

No I still have to run the reset and then the charging one works

placid geode
#

So, after 8:00 today, what does the trace of the reset automation show?

mortal path
mortal path
#

And I just tested the automation did not run. Then I manually run the reset one and as soon as I put my phone on the charger it ran

placid geode
mortal path
#

The main one and it was around 2 am

placid geode
#

Which timezone are you on?

mortal path
#

CST why?

placid geode
#

Well, it helps in understanding the time difference between you and us ๐Ÿ™‚

#

When it happens again, can you share the last 3 traces of the main automation

#

you can download the json files with the download button in the top right corner, and then share them through dpaste