Repeat Actions in Tesla Charge Warning Rule

So I made this rule to remind my wife to charge her car if it needs.
New Addition to rule: I wanted to repeat the TESLA switch "On" portion IF the car has not been plugged in and it meets the required expression.

I added this portion tonight but it seems like double duty when the Wait for Expression is right after the End-Repeat.

Thought's?

I have a similar, but much simpler notification rule for if my cars are not plugged in at a certain time. Your rule seems over complicated, and I'm not sure why you're doing a few things, but maybe I'm missing the point of what you're trying to do.

What does turning on the virtual switch do? Is the switch set for auto-off? I'm assuming yes, since you are turning it on repeatedly but never turning it off.

It seems like the While could just use the disconnected state. Is there any way the <15% criteria can change before the disconnected state changes? It seems like this will always exit due to being connected.

In other words, the car is under 15% and disconnected. As soon as it is plugged in, it is less than 15% but no longer disconnected. The While will exit due to the connection

If the car starts to charge as soon as it is plugged in, then the Wait for expression will immediately be satisfied by the 'charging' status, so including 'complete' seems pointless.

If the car is set for a scheduled charge and will not charge right away when plugged in, the light will stay red until the charge begins. Is that the intent?

Finally, why set the light to soft white then immediately to red, only to restore it later? Why not just set it to red at the top and then set it to soft white at the end in place of the restore?

Here’s what I setup. Since Tesla recommends that their vehicles always be plugged-in, the notification comes up shortly after arrival.


@Sebastien
ITs funny how there is so many ways to accomplish the same thing, sort of. lol

I love to see others RM rules... Wish there was a good set up for us to SHARE out rules and let the end-user import and replace the device with their own.

Maybe the next best thing would be to have an open dialogue subject with shared rules for others.. no sure..

1 Like

@Alan_F

The Tesla Switch is a VS that triggers Alexa audible message. IT is set for Auto-off.

I agree on the "complete" being point-less. I was making sure the rule works as intended before making alterations. I believe I will remove that portion.
Funny thing, Wife has hard time remembering to charge the car but since I made this rule, she seems to always remember right now. I feel like she is making sure so I can not test properly. LOL

On the mantle Hue color selection, I agree, I will make that adjustment as well. I was just trying to make sure it was not hung on red.

My rule just fires a single notification. Here it how I set it up in case it gives you any ideas for your rule:

Required expression: PowerSource of car not "mains" (taking my car info from this app: [BETA] Tesla Vehicle via TeslaMate MQTT). It is set for 'cancel pending actions if required expression becomes false' so it cancels when the car is plugged in.

Trigger: When car arrives home and stays that way for 30 minutes
.. (the app has a presence sensor attribute that 'arrives' when the car enters the 'Home' geofence)

I don't want to send a notification until evening, since we don't charge during the day and the car will often come and go multiple times during the day, so:

Actions:
IF time between 00:00 and 20:00 then
.. wait for event: time is 20:00
END IF
IF car is present then
.. Send notification
END IF

The result is that 30 minutes after the car arrives home, the rule queues up to notify me at 8pm. If it is already 7:30 pm or later, the rule will fire as soon as the 30 minutes has elapsed. If the car gets plugged in or departs, the notification won't fire.

1 Like

I noticed today that the rule was triggered for whatever reason.
The car is not home, which is a portion of the REQUIRED EXPRESSION.

If so, alternative to get around this? I had another trigger as MODE is evening but it was dependent on if the car was home or not. I removed it as a temp bandaid.

I wonder if its reading the present in the NOT present tag.

I am resurrecting the past to the present.. lol

I never go this to work right. Career got in the way for me to repair this.

Items in chain:
1- Light connector is for a specific light to flash colors when its not charging.
2- The Tesla switch controls an audible message when its switched to on, It has auto off.
3- Boolean is to prevent rule from running again while its charging up beyond 100 miles of range.

Goal for entire rule.
Trigger:
IF Johhny Three Arrives OR its 8PM

Event:
IF Johnny three is NOT plugged in
Then turn on Tesla Connector.
Repeat: When Johnny three is not plugged in
Tesla Switch on
Stop repeating when Johnny Three is plugged in.

Turn off Tesla Connector
Turn light to Green
Turn light to white
Turn light off
Wait for Johnny Three is 100 miles of range
Set Private Boolean to True

Else IF:
Johnny Three is charging
then wait till Johnny 3 is 100 miles of range
set Private Boolean to true.

Im sure I over complicated this entire thing.


Yes dont use contains use.=

ok- i will remove the = in the defined expression.

How does the rest look?

no you have it backwards use equals not contains..

ie

Why are you waiting until the vehicle has 100 miles of range? There is no actions following this… Do you just want the rule not to run again until that point?

An “END-IF” should be added at the end. Then, I would remove the “Set Private Boolean True” from the if conditions and just leave it at they end of the rule.

At least you know it :grin:. It took multiple readings of this rule to understand what it's supposed to do, and I'm still not sure I understand it. (Edit: I wrote this whole reply, mocked up a rule, and am still realizing this rule doesn't quite do what I thought it did)

Among the low-hanging fruit for simplifying this rule... I don't see what the ELSE IF section at the end does for you. You can probably remove it.

The rule actions will start at 8:30 or 30 minutes after you arrive, but only if the required condition of battery below 85 miles is met. If the car is charging at that time, you have the rule wait for the car to get to 100 miles and then do nothing. As suggested above, why not just have an END IF after the previous section, then have the set Boolean true outside the if/then?

That would result in the same result of doing nothing when the car is already charging when the rule is triggered.

Likewise, once the car starts charging, you turn off all the lights and switches but then wait for it to get to 100 miles of range and then do nothing but set the private boolean back to true. Why not set the private boolean true without the wait for expression?

It seems impossible for this WAIT to matter, since the rule only progresses to that point after the car is charging, and the car can't arrive (trigger) while it is already charging. This whole section is wrapped inside of an "IF car is disconnected", so if it were to re-trigger at 8 PM while charging, all of the actions would be skipped anyway on that instance of the rule execution.

Also, do you want this to run at 8 PM (or 8:30 really) when the car isn't home? It seems like there should be a presence check somewhere to make sure the car is at home.

There also must be a simpler way to handle the middle portion of the rule besides embedding a wait-for inside of a time-repeating loop.

I don't think this is exactly what it's doing. The Boolean is functional, but isn't preventing it from running 'while charging up'.

The rule only triggers at 8 PM and on arrival, whichever comes first. The Boolean is preventing it from running twice when you arrive between 7:30 and 8:00. If you only triggered 30 minutes after arrival, you wouldn't need the Boolean at all. I'm not sure what benefit you're getting from having both triggers.

Finally, have you had issues where the car begins to charge but never gets above 100 miles of range? Or do you find that you arrive home during the day below 85 miles and want to know when the car is above 100 miles so you can head back out on another drive? (Edit - on re-re-re-reading the rule I see it doesn't do that anyway, but maybe that's what you're trying to achieve?)

If the latter, then you might be able to set up the "car was below 85 but is now above 100" notification in a completely separate rule from the "make sure the car is plugged in 30 minutes after arrival" rule. (Edit: on re-re-re-re-reading the rule, I realize you're not getting any plug in reminder at all if the car is above 85 miles of range)

I described it earlier in the thread, but here is the rule I use to notify me if my car isn't plugged in, but only after 8pm, as we almost never charge during the day.

Here is a relatively simple rule to handle "the car is below 85 miles... make sure it is plugged in and let me know when it has at least 100 miles":

The initial 30 minute delay is handled in the trigger. If it is already plugged in the first WHILE loop will not run, but you'll still get the notifications for when the car hits 100 miles of range.

@Sebastien @Alan_F

Alan- How is your rule displaying the "current Status" of the items.. Example- you show 166 for current range. I do not have anything displaying on that. or nay others

Sorry for the delayed responses team....

The ESLE IF was only for the private Boolean.

The private Boolean would keep the rule from firing more than once, IF you started the charge, and needed to leave for something local.

  • This issue has arisen more than once. Normally from Kids and school related issues.

I have removed all the items that have "contains" and replaced them with the "="

Essentially.

Johnny Three arrives and after 30 minutes, IF the car is at or below 85 miles of range.
IF Johnny Three is NOT charging then
Repeat ( Tesla Connector and Switch)

  • Wait for Johnny Three is plugged in
    End Repeat
    change lights color and then off.
    Wait for Johnny Three range is 100
    set private Boolean to TRUE

IF Johnny Three arrives and after 30 minutes

  • IF Johnny three is charging
    Wait for Johnny Three range is 100
  • set private Boolean to TRUE

On the REPEAT Portion:
I have this stopping the repeat AND also added the END-REP. Im not sure if I need both functions.

Near the bottom of each rule in Rule Machine there is a toggle to "Display current values". I thought it defaulted to 'on'. Note the displayed values are not dynamic and you have to reload the page for them to update.

I'm still confused by your written explanation of what the rule is supposed to do. The rule is so convoluted that I'm finding it hard to organize my response.

You do not need a "repeat while disconnected" nested inside an "if disconnected". Just use a repeat loop. There is an example in the test rule I posted.

The IF statement you're using above the repeat loop is completely redundant. If the car is plugged in when the 30 minute delay is over, the "repeat-while" loop will be skipped because it only runs WHILE the car is disconnected. You don't need to check IF the car is disconnected before the repeat-while statement.

This is all you need:
Required Expression: car is <= 85 miles of range AND private Boolean is true

Trigger: when car arrives and stays for 30 minutes*

Actions:
Set Private Boolean false
While car is disconnected, repeat every 30 minutes
Turn on Tesla connector and switch
End-Rep
Change lights back to default color and turn off
Set Private Boolean true

  • This trigger format is preferable to triggering on arrival and then waiting as the first actions of the rule, because the way you have the rule triggering, if you were to arrive at 84% and then leave 15 minutes later without charging, the trigger will fire and the rule will start activating notifications while the car isn't home.

With your current logic, if you were to unplug at 99 miles of range and drive away, then return and forget to plug in, you'll get no notification as the PB will still be false and the 'wait for 100 miles' will never happen. The rule would remain inactive until the next time you plug in and charge to 100 miles. There doesn't seem to be any good reason to have any of the waits for 100 miles of range.

There is still an edge case where you arrive at <= 85 miles, 30 minutes later you haven't plugged in, but rather than plugging in, you drive away again to run an errand (say 35 minutes after initially arriving). The rule will keep firing the notifications until you plug the car in. There are ways to stop the actions if the car leaves, but that would only be worth it if you think that edge case is likely to happen.

Also I'm pretty sure you could remove the private Boolean from the required expression and from the rule actions and just have the first actions be "cancel pending actions". That way when the rule triggers again (because you left and then arrived again) the old repeat-while loop is canceled and a new repeat-while is started.

Here is an example that does everything your rule does but is much simpler:

What this rule does:

  1. Only runs when the car arrives home at <=85 miles of range and stays home for 30 minutes
  2. turns on the virtual switch and sets the lights. It repeats those actions every 30 minutes until the car is plugged in
  3. does nothing if the car is plugged in 30 minutes after it arrives. It does nothing if the car arrives with >85 miles of range even if it is never plugged in.

If this isn't what you're trying to do, maybe it would be easier to just explain what you want to have happen without trying to write it in a pseudo rule machine format:

It seems clear you want a plug in notification when the car arrives home with less than 85 miles of range. The test rule I posted above will do that.

Do you want a plug in notification at any time or under any circumstances when the car is NOT below 85 miles of range? Your current rule doesn't apply unless <= 85 miles.

Do you want something to happen when the car is charging and reaches 100 miles of range? You reference that mileage in your rule, but your rule doesn't actually do anything useful when it gets to 100 miles of range.

Why not just do something like i do. Get used to plugging in the car when u get home and if u havent after x number minutes or again at night time warn u.

Then just schedule the car to always charge at 4 am.

1 Like

I do the same. Always plug in the car (with nagging if we forget), and then have rule(s) that determine when to start and sto charging, and with what amperage.

1 Like