#Will my automation run like how I think it should?

1 messages · Page 1 of 1 (latest)

vocal quest
#

https://pastebin.com/kcDvYVvr

I want my charger to turn on not earlier than 8:15pm. My charger IoT class is Cloud Polling. I am not sure how often this is updated.
I only want my charger to turn on if it is plugged in.

I created an automation where it will update the status of the charger to see if it is plugged in every 30 minutes between 8:14:59pm and 12am.

I have not yet created the timer part for the weekdays. I will if my logic for the weekend works.

On the weekends. I will finish charging anywhere between 1-5 hours. I created a one hour timer up to a a six hour timer. After one hour, the automation will update and see if charging is completed. If charging is completed, charger will turn off. After two hours, the same thing up to six hours.

I just realized I could probably get rid of this section.
then:
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
after: "20:15:00"

#

on the weekdays, I will create timers for different lengths of time since it takes longer to finish charging than on the weekends

narrow umbra
#

I would use schedule helper which tells me if action is allowed and use this in a condition

#

and use the time pattern based trigger

#

I really don't see the pastebin.com link as it seems to not find DNS on the domain for my network for some reason

vocal quest
#
alias: Charger On
description: ""
triggers:
  - trigger: time_pattern
    minutes: /30
conditions:
  - condition: time
    after: "20:14:59"
    before: "00:00:00"
actions:
  - if:
      - condition: state
        entity_id: binary_sensor.charge_cable
        state: "on"
    then:
      - condition: time
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
        after: "20:15:00"
      - action: switch.turn_on
        target:
          entity_id: switch.charger
        data: {}
  - if:
      - condition: state
        entity_id: binary_sensor.charge_cable
        state: "on"
    then:
      - condition: time
        weekday:
          - sun
          - sat
      - action: switch.turn_on
        target:
          entity_id: switch.charger
        data: {}
      - action: timer.start
        metadata: {}
        data: {}
        target:
          entity_id:
            - timer.charger_one_hour
            - timer.charger_two_hour
            - timer.charger_three_hour
            - timer.charger_four_hour
            - timer.charger_five_hour
            - timer.charger_six_hours
      - action: homeassistant.update_entity
        data:
          entity_id:
            - sensor.charging
      - if:
          - condition: state
            entity_id: sensor.charging
            state: complete
        then:
          - action: switch.turn_off
            target:
              entity_id: switch.charger
            data: {}
mode: single
rustic ruin
#

Please format your code

soft basinBOT
#

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.

rustic ruin
#

I would flip that logic around

#

seems that you want to trigger when the charger is connected or it's after 8:15pm, so those are your triggers

#

you can also have one that triggers if the charging sensor reflects "complete"

#

I suggest that you find out how often the integration polls rather than trying to create your own polling loop

#

seems like you're making the automation much more complicated, including adding timers, just because you don't know

vocal quest
#

how would I find out how often the integration polls?

#

I tried googling Cloud Polling for HA and could not find anything

rustic ruin
#

from the integration docs or code

#

what is the integration?

vocal quest
rustic ruin
#
VEHICLE_INTERVAL_SECONDS = 300
VEHICLE_INTERVAL = timedelta(seconds=VEHICLE_INTERVAL_SECONDS)
#

as I read it, there's a max of 15 minutes between polls

vocal quest
#

where did you find the code?

rustic ruin
#

there's a link on each integratin page

vocal quest
#

sorry I should have been more clear, where in the github did you find the code?

rustic ruin
#
core/homeassistant/components/tesla_fleet
/coordinator.py
#

The coordinator is what does the polling

vocal quest
#

Thank you! I'll do more digging to figure out how often this integration polls

#

then I'll rewrite the automation again