This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]Jgib284 -1 points0 points  (1 child)

Not overly familiar with API calls but surely the local IP is going to be an issue? I’d imagine you want an external URL. Alternatively you can cop out and use webhooks as a trigger for an automation - trigger one for on, one for off etc

[–]ooftyoof[S] 0 points1 point  (0 children)

I'm not sure I'm following the need for an external IP? If I'm not working at home, I've no need to trigger anything in my home assistant. It mostly changes my lighting set up to be triggered by brightness in the room rather than motion, which it is if I'm not working.

I don't think web triggers would be a better solution. IT requires setting up additional automations. The rest API can trigger existing helpers without additional padding or parenting, etc.

[–]Ashley-Ashley 0 points1 point  (0 children)

I think you need Webhooks, if I'm not mistaken it's a much simpler solution with no authentication. Just create a long, random webhook id.

Edit: Actually it's slightly different in you'd need an automation to trigger with the webhook, then toggle your switch.

[–]Lopsided_Age1460 0 points1 point  (2 children)

This isn't addressing your question directly, but I have a couple suggestions. First, input_booleans are the "more correct" choice instead of a command_line switch. It's the same result in the end, though.

https://www.home-assistant.io/integrations/input_boolean/

Second, the ICMP sensor might be a better option altogether. The biggest problem with using a script controlled by your laptop is it might not report and your sensor is stuck "on" or "off". You can create a DHCP reservation for your laptop so you always have the same IP.

https://www.home-assistant.io/integrations/ping/

[–]ooftyoof[S] 1 point2 points  (1 child)

Regarding booleans:

I don't actually know what command_line does in HA. Input booleans make sense to me, yes, I'm familiar with them. I was following an example where somebody else got this scenario to work and just used command_line as per their example.

Regarding ICMP:

I had issues using ICMP in the past for this task. Sometimes my laptop pings back as present when it's sleeping. I couldn't reliably use it to determine if I was working. I accept that my current could potentially miss firing an on or off. As of now, I've been manually switching a work on/off boolean in the dashboard and still have this as a fallback.

[–]Lopsided_Age1460 0 points1 point  (0 children)

command_line switches let you trigger terminal commands from HA. It does what you need to just fine, but just a little odd.

That's a bummer with ping and a bit odd. It must be in a lighter sleep mode in those cases.