No major question here, just thought you might find this interesting. It’s an example of the kind of (off-the-wall) things you can do with HA that aren’t immediately obvious. When I was starting out with HA, I enjoyed reading these examples, because it gave me ideas for my own setup. And, I wrote many automations that should really be scripts, so hopefully this will help someone avoid that and recognize the power of scripts early.

At home, my laptop from work sits (closed) on a stand under the monitors. I have a docking station for it, but the docking station doesn’t have a power button to start the laptop (the official Dell docking stations have a power button, but other brand of docking stations don’t). So, since I got that stand a few weeks ago, I’ve been pulling the laptop out and opening juuuuuuust enough that I could reach the power button, then closing it and sliding it back into the stand. There had to be a better way that didn’t involve buying an expensive Dell docking station.

The docking station power is on a Sonoff S31 outlet (flashed with Tasmota, not that that’s important here) that is remotely controllable. Long ago, I set up HA automations that turned on the S31 when the laptop was detected on the network, and shut off the S31 after the laptop dropped off the network at the end of the day (leaving in a time delay so it didn’t shut off if there was a momentary network glitch). So, I’d boot the laptop, and a moment later the docking station would kick on and connect the mouse and monitors to it. And the end of the day, I shut down the laptop, and a few minutes later the docking station shuts off automatically.

I recently discovered the Wake on LAN integration. So, after setting that up, I wrote a script that turns on the S31, waits a while*, then triggers the Wake-on-LAN for the laptop…and it boots up! With HA, I can start the boot process while I’m still relaxing in the living room before starting work; in theory I’ll go into the office and it’ll be ready for me to log in.

Heck, if HA knew for certain it was a workday, it could boot the laptop for me…hmmm. Maybe something to think about for the future.

*How long? Well, 30 seconds seems to be too short; the laptop doesn’t respond to the WoL command after just 30 seconds with power applied. It did work this morning when I waited several minutes to try it again. I just changed the delay to 1 minute and will see how that works tomorrow.

I also added a repeat loop (starting after that 1 minute timer) with three components:

  • A condition that looks for the laptop being “Away” on the network. (If it is “Home” on the network, the condition will end the script.)
  • If it is, then it tries the WoL command again.
  • Then waits 30 seconds and repeat.

The repeat loop counter is set to 3, for a total of 4 attempts to start the laptop. I’ll check the traces and see when it starts working, and set the initial delay accordingly, so that in general it shouldn’t need the repeat loop.

If people want, I can post (sanitized) YAML. But I do like explaining the process rather than just posting code.

  • Strit
    link
    fedilink
    English
    76 months ago

    Very nice idea! I didn’t know there was a wake on lan integration. I should try that for my desktop. :)

    • @limelight79@lemm.eeOP
      link
      fedilink
      English
      3
      edit-2
      6 months ago

      Thanks. You have to set it up in YAML - there’s no GUI. Here’s the page on it. Obviously you need to know your adapter’s MAC, but that’s not usually too hard to find.

      It sets up a switch entity, which is a little odd to me, because it’s not an on-and-off device - toggling it just triggers the WoL command. But I guess that makes the most sense; I don’t think there’s a “button” entity.

      Edit: It does look like the entity can track the status of the computer, but it’s not working for me. Hostname is probably not correct.

    • @limelight79@lemm.eeOP
      link
      fedilink
      English
      16 months ago

      My work one, yes. They want us to shut it down every night. I just suspend my personal laptop though.

  • LifeBandit666
    link
    fedilink
    English
    36 months ago

    Yeah WOL was one of the first things I looked for in HA because I just didn’t have all that much in the way of Smart stuff.

    Anyway nowadays I have an automation you may like. I have set up a little wireless dock for my phone on my desk. It’s the only wireless charger I use, so using the Companion app sensors (namely the charger type) I have set up an automation that turns on my PC when I dock my phone.

    Meaning I literally flop down on my chair and put my phone on the charging stand and the PC turns on.

    Now when that PC is picked up on the network HA will turn on my monitor (via a smart plug) and my desk lamp.

    I also have a program on the PC that detects what I’m doing, and can switch the PC off!

    So I can add switching the PC off to my automations, like my Goodnight automation

  • @fuckwit_mcbumcrumble@lemmy.dbzer0.com
    link
    fedilink
    English
    2
    edit-2
    6 months ago

    FYI OEM docks are CHEAP used once they’ve been out for a few years. And no you can’t mix docks from other OEMs and have the power button work since there’s no standard for it.

    I’ve found aftermarket ones to be super unreliable though, especially if you use HDMI and power from the dock.

    • @limelight79@lemm.eeOP
      link
      fedilink
      English
      26 months ago

      Yeah, I’ve seen some used Dell ones cheap. But then I might want to use it for my personal non-Dell laptop, and who knows how that will work.

      The one I have came from Amazon 3 years ago, and it has worked perfectly. We’ve been full-time work from home in those three years, so it has gotten a good bit of use.

      • @fuckwit_mcbumcrumble@lemmy.dbzer0.com
        link
        fedilink
        English
        16 months ago

        The docks will work with anything that has Thunderbolt 3/4. It’s only the power switch that won’t work, and you can’t do the breaking USB spec of charging over 100 watts @20v. The downside is those OEM docks tend to be Thunderbolt only, and if you connect it to a USB only device it will either not work at all, or have SEVERELY limited functions.

        Is yours a dock dock or just a big hub? I don’t really have much experience with the dock docks, but I know the overgrown hubs we use at work love to burn out the HDMI converter chips, but usually work well enough besides that.

        • @limelight79@lemm.eeOP
          link
          fedilink
          English
          16 months ago

          I’m not sure if it’s a dock dock or a big hub. It’s a USB-C connection, so maybe the latter. It’s definitely not one of the old style with the proprietary connector.

  • @Reygle@lemmy.world
    link
    fedilink
    English
    2
    edit-2
    6 months ago

    So all that effort to spare 1 watt of “suspend” power? Running home assistant all day long probably burns 500x that power.

    I have to be missing some detail because that sounds absolutely insane in my head.

    • Panq
      link
      fedilink
      English
      36 months ago

      You’re right in that running HA just for a WoL timer would be silly, but (presumably) it’s already running for other, less silly purposes.

      I’d say the main benefit is when the machine requires regular (as in daily) reboots, or if it’s something you don’t trust is fully private and want to be powered off outside work hours. Not useful for me, but I can see why it would be handy.

  • @TedZanzibar@feddit.uk
    link
    fedilink
    English
    15 months ago

    I have my dock plugged into a smart plug and the laptop set in the BIOS to turn on when it receives power. I have an NFC tag on my coffee machine that I bloop while I’m making my morning brew, and that turns the dock on so that everything’s ready when I move into the office.

    For turning things off I have HASS.Agent installed and sending state updates (locked, unlocked, etc, which is useful for other automations) and when that sensor goes unavailable for 15 minutes it turns the plug off. I find that’s long enough to allow it to reboot for updates and what not.

    The sensor does report shutdown, reboot, and sleep states but I found that it often happens too quickly to get the change sent, so the unavailable state is more reliable.

    • @limelight79@lemm.eeOP
      link
      fedilink
      English
      15 months ago

      Yeah, unfortunately, I do not have access to the BIOS, nor can I install things on it - security restrictions. What you have done would have been a lot easier and more reliable though!

  • @grue@lemmy.world
    link
    fedilink
    English
    16 months ago

    Heck, if HA knew for certain it was a workday, it could boot the laptop for me…hmmm. Maybe something to think about for the future.

    I’ve been meaning to look into how to integrate HA with a NextCloud CalDAV server or something, because I have a lot of ideas for automations that would be best triggered by calendar events (e.g. ringing an alarm [get ready time] + [travel time] before [appointment]).

  • @CondorWonder@lemmy.ca
    link
    fedilink
    English
    16 months ago

    I do this with my desktop - I work from home so it’s really nice to have my PC ready by the time I get down to it. There’s a workday integration too, set your typical schedule and it’ll be true when it’s a workday - with a motion sensor as the trigger as my start time varies if I have meetings In the morning.

    This is one of the first things I set up with HA for fun but the convenience is really nice.

  • Loren
    link
    fedilink
    English
    15 months ago

    I remote in to my home PC while at work for various reasons every day, so I have it set up to wake it up when I get to the office and it works great. The Wake on LAN integration is so rad.