What Is Your Most Useful Automation?

I’ve been through several iterations of this and have landed on one that I really like that works perfectly every time. I had started with “if the internet is out for 5 minutes then toggle the power for 30 seconds and toggle it back”. The problem is that on really long outages I was constantly powering my modem off and on and sometimes that by itself was the problem. What I do now is this:

  • Internet goes down for 5 minutes
  • Power cycle the modem
  • Increment a helper entity that serves as a counter
  • Continue doing this 5 times (or 25 minutes of power cycling)
  • If still down, at cycle 5, now use 15 minute cycles (the original automation won’t fire past the helper being 5 cycles)
  • If still down after 8 15 minute cycles (2 hours more), switch to 30 minute cycles
  • If still down after 4 30 minute cycles (4 hours more), switch to 1 hour cycles until it comes back up
  • When it comes up reset the helper back to 0
  • At each iteration, including initial off and initial on, create a persistent notification so I am aware of what is going on
  • Create recorder entries for every part of this so I can give it to the cable company and say “this is how long you were down”
4 Likes

This is interesting. Is this internet reset / counter / notification / recorder automation yaml available somewhere in this forum or on github…?

1 Like

No, I wrote it but could probably post it here, just some automations, some helpers and some template sensors.

1 Like

Good point about extended outages. I havent actually automated it or even used it other than to trouble shoot over the phone when customer service tells me to unplug for at least 10 seconds.

Here’s how I do it:

Automation for every 5 minutes (adjust this for your 15/30/60 minute restarts as needed):

alias: "Action: Restart Internet Every 5 Minutes"
description: >-
  This is the result of the internet being down and starting the process of
  rebooting the modem every 5 minutes for the first 30 minutes (count 6)
trigger:
  - platform: time_pattern
    minutes: /5
condition:
  - condition: and
    conditions:
      - condition: numeric_state
        entity_id: input_number.internet_reset_count
        above: 0
        below: 7
      - condition: not
        conditions:
          - condition: state
            entity_id: binary_sensor.internet
            state: "on"
action:
  - service: persistent_notification.create
    data:
      message: >-
        The Internet router has been rebooted in response to the Internet being
        down
      title: Router Reboot (5 Minute)
      notification_id: routerrestart
  - service: script.internet_down
    data: {}
mode: single

That part creates a notification in addition to restarting via the script. I mention this because I use ID’s so I don’t get dozens of notifications, it just updates the one so I know when last it ran.

Then my script (you could put this directly in the automation itself, I just did it here because when I re-use something I try to use a script so I don’t have multiple places to update things). I have an automation that runs when the internet has been down for 5 minutes that increments the helper the first time, that then allows these to fire on their schedules afterwards:

internet_down:
  alias: Internet Down Restart Network
  icon: mdi:web
  sequence:
    - service: input_number.increment
      data: {}
      target:
        entity_id: input_number.internet_reset_count

    - service: homeassistant.turn_off
      data: {}
      target:
        entity_id: switch.aeon_labs_dsc11_smart_strip_switch

    - delay: 00:00:30

    - service: homeassistant.turn_on
      data: {}
      target:
        entity_id: switch.aeon_labs_dsc11_smart_strip_switch

Other than that it’s just having the helper entity in place for the counter. I also have a button on my dashboard to run the script manually because more often than not I notice the outage long before the 5 minutes the automation is waiting for and start the process by hand, the automation is more for when I’m not home (I’m in my RV a lot in the summer) so it takes care of it.

Speaking of RV or being away in general, I not only have a thread about my RV you can find on here but I also have a backup DSL line on a failover switch that kicks in if the cable is down so I’m still online, as well as having a laptop running while I’m gone that has a wired connection to cable and a wired connection to the DSL network and then a wireless to a cheap cellular hotspot on a very small plan so I can always take control of that laptop remotely if all hell breaks loose and diagnose anything. I also have several Shelly and Kauf ESP plugs where I can connect to their internal access points to force power cycling of critical systems, like if HA got locked up (which has happened a few times) or the firewall is in a bizarre state, both have programming to power their outlet back on after 1 minute in case the act of turning them off kicks me out of my remote access for any reason.

One area this gets used a LOT is at night when I’m sleeping. The internet will go down and this system just takes care of it and it’s usually fine when I get up. I see the notifications probably once every couple of weeks that it was out for an hour or two in the middle of the night as they did maintenance at the C.O.

1 Like

I just created another really cool automation, most certainly my favorite of all time so far. I’m beginning a top-down re-do of my entire HA to optimize it and make it actually smarter. In that I created a new system for controlling all my curtains and shades (aka covers).

What I had been doing up to now is setting each shade to some percentage based on what was happening. For example, when waking up then my scripts and automations had long sequences of “cover.open_cover” for a dozen covers. The same with many other things like going to bed or ramping down for the evening while watching TV, so on. I have a LOT of things that control my covers.

The problem with this is it is a huge pain to maintain as I come up with new “events” for which my covers are impacted I have all sorts of places to fix this up. Also as I add more and more covers to my house, again I have to touch dozens of automations and scripts. This was also slow, it often took several minutes to control multiple shades as each event fired and completed before the next event.

The new system is really cool. It starts with a sensor template, in which I have attributes for each cover in the house, each attribute is a DICT of settings of how to control each shade under certain “events” (wake up, go to bed) and then exceptions for each “condition” (climate changes, vacation mode, etc). Each attribute looks like this:

      #############################################
      # SIDE CURTAINS
      #############################################
      curtains_side: >-
        {{
          {
            'adaptive_cover_entity': 'vertical_toggle_control_side_sliding_glass_door',
            'adaptive_cover_insun_entity': 'horizontal_sun_infront_side_shade',
            'events': {
              'awake': {
                'value': 100
              },
              'evening': {
                'value': 50,
              },
              'sleeping': {
                'value': 0,
                'conditions': {
                  'swamp': 30,
                },
              },
              'shower': {
                'value': 0,
                'conditions': {
                  'swamp': 30,
                },
              },
              'shower_done': {
                'value': 100,
              },
              'end_mitigation_parity': {
                'value': 100,
              },
            }
          }
        }}

Then I have a script to control each shade based on these parameters. It first looks to see if the entity name is in the attributes of the sensor, if so then it looks to see if there is an event configured for the one being processed (i.e., awake), then sets the percentage to set the cover to the “value”. If it finds “conditions” within the event, it evaluates those conditions to see if there is an exception (i.e., if my swamp cooler is on and I need to leave the shade open slightly for venting). The result is the percentage that the cover should be at by the end of this run. You’ll see this in my side curtains posted above, the curtain set to 0 (close) when we shower, but if the swamp cooler is on it instead only closes to 30%. This script is set to run in parallel so that when fired on a house-wide scale it opens almost all covers simultaneously (rather than one-by-one).

This script also knows when to end mitigation (when I button the house up on really warm days), when to enable/disable adaptive covers to automatically adjust the cover to the point of letting too much direct sunlight into the room and more.

Finally a second script serves as a master script, it simply takes an event as a field (i.e., Waking Up that translates to “awake”), then runs through every single cover and sets it to the matching event value (with conditions) - it then takes the entity ID of a found cover and sends it to the first script to set the percentage of the cover.

Now the only thing I ever have to do is edit the sensor template to set all the ways I want a cover to be set based on events and conditions, no more editing dozens of automations or scripts, that one single sensor enables all automation to just always work.

Truly this is not only significantly smarter than dozens of automations, it also allowed me to remove a lot of automation and script sequences and the cherry on top is that controlling every cover in the house went from several minutes to about 45 seconds.

5 Likes

Here are a couple interesting spa/hot tub related automations:

  • Have the hot tub just ready at desired temperature by a certain time regardless of current water temperature (uses an input_datetime helper, along with an input_number of seconds to heat the tub by one degree.)
  • Turn off the outside speakers 10 minutes after the spa pump stops running (so as not to annoy neighbors all night if i forget!)

I just made a post of my voice activated timers using Willow. They are named how you want, persistent across reboots, and you decide which Willow device (or all devices) to have the automations respond.
Timer with Willow Voice / Named / Persistent - Share your Projects! - Home Assistant Community (home-assistant.io)

Electric Hot Water Tank Solar Powered

Based on Solar production threshold my automation sets an inline switch to on/off which powers a mechanical relay to supply power to the hot water tank. (3.6Kw) The tank temp is tracked by an Ecowitt thermometer (mounted externally in an unused tank plug) which is also used to disable supply power when at desired temp. When the tank thermometer triggers, a notification is sent, this is achieved by monitoring power consumption on the tanks phase. If solar production is insufficient on any day, a night time (off peak) temperature based automation triggers to turn on the relay and heat the water. This ensures hot water temperature is always available in the morning.

Previously I used Gas Hot Water but when that tank failed I replaced it with the setup as above (400L). I estimate I am saving > $2000 in off peak power by using my available solar. My solar is 12Kw Enphase based.

This thread is great. There are some very inspiring stuff in here.

My most useful automations are:

  • Power Outage Handlung
    During Power Outage my solar batterie takes over but the automation shuts down all major consumers like dishwahser, washing machine, dryer and car charger. Furthermore it calculates the remaining batterie duration on base of my base power consumption and sends a priority notification to my phone.
    Last thing it does is to create a permanent notification to remind me of turning on the major consumers oncy power is back again
  • TV / Entertainment power outlet has not been deactivated at 22:00
    I check if the TV is still connected to my router at 22:00 because I want to shut down the entertainment power strip at night. I do it manually because just cutting power is not very device friendly especially the playstation is complaining if you just cut the power. This automation is a friendly reminder to take action.
  • Heat up bathromm before my wife returns from a late shift.
    I have all my wifes work shifts in a google calender. Whenever a late shift ends it heats up the bathroom and activatse hot water if otherwise deactivated.
  • Advanced Heating control / Cover Control Automation in combination with WebUntis integration
    Ok, not really my automation but the WebUntis integration provides access to the school calender of my big kids. I use this to identify if they have to go to school or if they have a free day. Advanced Heating Control & Cover Control Automation make use of this to set the correct heating schedule or to allow the covers to stay close longer
1 Like

The simplest automations are the best:

  • Switch the dimmer of the corridor by motion detection. From 22:00 it’s darker, from 00:00 it’s very dim so that it doesn’t hit my eyes when I go for a pee at night
  • I use the geolocation + SSID of two mobile phones to switch the mentioned motion sensor to alarm mode and send push messages if someone enters the flat
  • I can switch on the espresso machine with NFC next to the bed. After 15 minutes, the light next to the work surface switches on and signals that the machine has warmed up.
    If I switch off the machine and switch it on again within half an hour, the light switches on immediately because the residual heat means the machine is warm again straight away
  • When I switch off the RPi, the 3D printer also switches off
  • Push message when the batteries of the IOT devices are empty
  • NFC-Tags in the cars to open the garage

On : * Notification when washing machine finished its job.

Do U have a sensor that “feels” done - if so what sensor ??

Nope, I have Shelly 1PM installed inside outlet to measure the power consumption and I added automation that triggers when power consumptions drops below 1W (that seems to be standby consumption for my washing machine) for 1 minute. Working very reliably so far.

1 Like

I use a Aqara vibration sensor. Tell Christian I said hi :wink:

I started to write upp all my best automation but then realized they all depend on your specific needs and uses, so I stopped and just gave some
We have so many (not mostly complicated) but here are some examples:

  • When some of us start to shower: In the morning on working days it turn on the news on the speakers in the bathroom, otherwise in the weekend or in the evening it turns on some lounge music.
  • We use calendar together with TTS to tell us if something is happening today, birthdays, national holidays, history about the day, special occasions etc. (with the help of OpenAI) when we wake up and during the day at specific times,
  • I have one automation (triggered by a switch in the bedroom) , when we go to bed to lower the shields and adjust the lights in the bedroom and in the rest of the adjacent rooms. The same switch (in the morning) opens the shields adjust the lights and TTS greets us and gives us the relevant information, stated above.
  • My office is in a Star Wars Style so when I enter the room my Millenium Falcon shoots its lasers :slight_smile:
  • All the appliances tell me when they are finished, the coffee machine tells me when the coffee is fully brewed
  • Oooh, I have soo many
2 Likes

Just stumbled on this thread…
In my case the most useful automations are HVAC related.

  1. very basic but saved me the hassle of pulling some new wires: start the underfloor heating circulation pump when heating is active and stopping it after 15 minutes of boiler) heat pump inactivity. If the pump or automation fails the room get heated by fan coils that have smart but autonomous thermostats

  2. when my PV batteries are full and I m feeding too much PV power to the grid and temps are high crank the cooling to full blast in all the rooms, stop cooling when start drawing from battery power and if nothing has been done on the settings (temps or mode changes on the fancoils)

4 Likes

Bathroom exhaust. My most liked:

  • Hot … and thermostat in cooling mode turn on exhaust fan.
  • Hot … and thermostat in heating turn on HVAC fan.
  • Humid and average indoor humidity is below 50%, turn on HVAC fan.
  • Humid and over 50% average indoor then exhaust.
  • When humidity spikes take prior readings room temperature as surface temperature and if within 5 degrees of dewpoint at the surface temperature turn on exhaust fan and if within 2 degrees also turn on HVAC fan to limit the mirror fogging.
  • Max run time is 25 minutes for all of the above. If the light in the bathroom turns off within that 25 minutes the timer reset.
  • Controlled turn off is when the humidity change in the space on decreasing less than 0.5% over a 3 minute period. If run ing due to heat it is 0.5 degrees over 3 minutes.
  • Email notification that one of 5 local fuel stations has just increase petrol price by 25c or more - means the regular up/down fuel cycle has changed to UP!
  • Google Home Broadcast to empty the washing machine when it is finished - uses power measurements to determine when finished, and keeps notifying until emptied (however new washing machine turns itself off when finished which screws it up a little)
  • Google Home Broadcasts about doors being left opened for either too long, at night, or when cold.
  • Reset the wifi light switches to their default when ever someone accidently gets Google to turn off ALL the lights rather than the lights in the room they are in
  • Flood sensors in all wet rooms - Google Broadcast, plus siren about potential sink, bath, washing machine leak
  • motion sensors to turn on lights in certain rooms

I do the same, but for now have no way to to know when the washer it’s been emptied because it turns itself off at the end of the cycle too. It’s a SmartThings washer but I haven’t wanted to bother opening the firewall for their push endpoint and possibly fighting to make it go through my proxy.

Just put a door sensor on it.