Template as sensor argument?

Is it possible toi use template in sensor definition, but not to customize output of sensor, but dynamically change it input? I have snmp sensor, that reads from my router IP address of default gateway on ISP side. I’d like to use this IP in ping sensor, so I can always ping the first device in ISP network, even if my IP changes. I’d like to see something like that:

binary_sensor:
  - platform: ping
    name: "default gateway latency"
    count: 1
    scan_interval: 60
    host_template: >
      {{ states('sensor.snmp_gateway_ip') }}

Obviously it does not work (and I tried several variations of syntax), so just wondering if it is possible at all?

No, none of the ping binary sensor options accept templates.

Does the gateway have a hostname?

Nope, only IP.
And this is what I was afraid of…

Does your ISP really change it’s gateway that often?

Usually it’s just the clients (your router) that get dynamically reassigned IPs.

Well, if everythign works fine, the connection might be stable for moths… But recently I’m experiencing lots of issues… Not sure if they are doing some maintenance, or it is influenced by weather conditions, but almost every day, sometines even few times a day I have some shorter or longer breaks. Once the service is restore it is somehow random if my external IP and default gateway change or not. So that’s why I started to investigate if I can somehow automete changes in config :slight_smile:

Perhaps you could call the ping command with a command line sensor. It accepts templates.

Yeap, I was thinking of it… though I do not love playing with parsing command line responces, too lazy to learn grep properly :smiley: But htis indeed might be way to go!