Secret won’t work in wake_on_lan? Or is it automations?

Hi all,

I’ve rebuilt my HomeAssistant from the ground up earlier this year, after the Pi I was running it on died, used that as the kick in the pants I needed to re-layout my whole home network.

I hadn’t bothered to get the TV back set up for control as I mostly use it with a PS5 and AppleTV which took care of most things over HDMI-CEC.

Previously I had had this TV working with wake_on_lan using:

media_player:
  platform: webostv
  turn_on_action:
    service: wake_on_lan.send_magic_packet
    data:
      mac: !secret lg_tv_mac

which was working til either late January or early February, whenever the Pi went down. Obviously I initially set it up a very long time ago

Now I’m trying to get it all set up again so I can attempt to make a combined controller for the tv and my new AVR. And in doing so I have learnt that how to configure the wake_on_lan stuff has all changed, probably because LG webostv is “configure from the UI only” now.

So I tried to set it up via the automation method in the docs, however via the UI automation flow, !secret substitutions don’t work, and that is not something that is going to change based on the GitHub bug report on the subject.
So I tried the workaround of making a separate automations.yaml mentioned in the GitHub thread which got me closer, in that the automation can be saved and doesn’t produce an error, but now when it runs it produces an error from the wake_on_lan integration itself:

Error: non-hexadecimal number found in fromhex() arg at position 12
Result:
params:
  domain: wake_on_lan
  service: send_magic_packet
  service_data:
    mac: '!secret lg_tv_mac'
    broadcast_address: 10.42.107.255
  target: {}
running_script: false

I should note that calling the wake_on_lan.send_magic_packet service with the MAC address and Broadcast IP using the developer tools services section works fine, however that section doesn’t support !secret fill ins either so I don’t know if it is a case of all automations do not support secrets anymore, or if wake_on_lan does not likel how the MAC address is formatted from the secret, which is:

secrets.yaml

lg_tv_mac: “AA:BB:CC:DD:EE:FF”

Anyone have experience getting this to work? I am aiming to keep using the secrets bit as I have my IoT subnet served IPS from HomeAssistant’s DHCP addon, so having each IP and MAC address only in one place and just referenced from there is very useful, particularly when something breaks and needs to be replaced.

configuration.yaml

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
automation secret: !include Configuration_Files/Automations_with_Secrets.yaml

wake_on_lan:
Automations_with_Secrets.yaml

- id: [*redacted*]
  alias: Turn on LG TV
  description: Turns on LG TV via Magic Packet
  trigger:
    - platform: device
      device_id: [*redacted*]
      domain: webostv
      type: webostv.turn_on
  condition: []
  action:
    - service: wake_on_lan.send_magic_packet
      data:
        "mac": "!secret lg_tv_mac"
        broadcast_address: 10.42.107.255
  mode: single

2 things I see:

I’m not sure “!secret” between quotes work. Try without.

Those are typographical quotes. Most likely just a copy/paste issue, but be sure you are using “plain” ascii quotes in your actual yaml.

1 Like

This guy right here! It was the quotes on the secrets reference. When using secrets in the config of addons, you are meant to quote them, and most of my yaml’ing in this instance of homeassistant has been in my addons, DHCP, DNS, and so on.

Thank you! I figured this was either gonna be a real little oversight by me, or some super niche bug effecting how I was specifically using it all that probably will never be fixed. Very glad it was the first one :slight_smile:

Oh and yes, the double-quotes in the secrets file are definitely ascii quotes :slight_smile: