How to use an invariant URL to activate a device

I'm trying to send a short MP3 file to a Google Mini to play a custom sound. I use a static IP (assigned by my router) for my Hub: 192.168.1.61. The hub name on my LAN is "hubitat-c8p-house". I'm on a C-8 Pro, latest beta firmware.

I'd like to make the action use an invariant (alias) URL so that if I change the static IP of the hub to another value, I don't have to remember to update my rule.

This action works:

playTrack('http://192.168.1.61/local/beep-08b.mp3') on Speaker - Office GO

These 2 versions of that action do not work:

playTrack('http://127.0.0.1/local/beep-08b.mp3') on Speaker - Office GO
playTrack('http://hubitat-c8p-house/local/beep-08b.mp3') on Speaker - Office GO

Is there a way to accomplish my goal?

What is "Hub name on LAN" (not "Hub name") set to in Settings > Hub Details, and does that work?

127.0.0.1 won't -- you have to look at this from the perspective of the Google player.

Would a variable string work? Then get the IP address at boot and shove it into that variable?

2 Likes

"Hub name on LAN" = "hubitat-c8p-house"

Thank you! That worked:

The virtual device, "VD Hub Information", uses the driver "Hub Information Driver v3" from @thebearmay.

1 Like

Did you try the actual mDNS name of hubitat-c8p-house.local? (I see you have another solution, but this is where I was going.)

I just tried these, no joy:

I'd like to make the action use an invariant (alias) URL so that if I change the static IP of the hub to another value, I don't have to remember to update my rule.

That is the very definition of the purpose of a hostname. Simply use the name of target device, and let the router do mapping to an IP address, whether static or dynamic.

Working example please, in the context of a Hubitat hub?

Because I tried using the assigned “hub name on LAN” as a “host name”, and I couldn’t get it to work.

In general, I believe you’d do this with a DNS server that runs locally.

For example, I can browse to https://hubitatc7.lan because I’m using pi-hole running on a raspberry pi for DNS on my network.

From the pi-hole interface, I can map a hostname to an IP address. My router tells DHCP clients that DNS is provided by pi-hole. So anytime a client on the LAN asks for that hostname, it asks pi-hole, and pi-hole supplies the IP address.

All that would assume google minis will use a DHCP-assigned DNS server. Some IoT devices will ignore that and only reach out to a hardcoded DNS, like 8.8.8.8 (Google’s public DNS).

Yes, exactly.

In the original poster's case, their router (providing hostname/IP info via DHCP) most likely is also acting as a DNS server, or can be configured as such.

If (when) DNS is active on the router, the address of the router should be the first DNS server provided by the router to DHCP clients. This means that queries by the Google Mini speaker for local hostnames (ie., hubitat-c8p-house) will result in local IP addresses (192.168.1.61) when it is given a URL (http://hubitat-c8p-house/local/beep-08b.mp3)

1 Like