Hi.
I have a light on a different host system that I can control with MQTT via a command like: mosquitto_pub -m '{"brightness": 0}' -t '$hardware/status/reset' -h ninjasphere.local
That is, I need to use -h : mqtt host to connect to. Defaults to localhost.
Is there a way to specify a different host to send MQTT commands to? I didn’t see it in any config options.
It’s only for this one… I want the normal MQTT topics on the HA host for everything else?
My light is on another system, which has its own MQTT broker. I don’t know how to change that.
I guess I could use a command line switch, but I’d rather it be a “light”.
Thanks.
Somebody created a bridge between their local broker and cloudMQTT, which might be useful. But having two brokers on a local network is an unusual situation.
Thanks.
Failing this idea… is there any way to tell HA that a switch should be treated like a light?
I could make this a command_line switch and I also have a power socket that I use for a lamp.
I’d like to be able to ask Siri to “turn off the lights” and have it turn the socket (and command_line switch) off too.
EDIT: looks like https://home-assistant.io/components/light.template/ might be the solution…
Thanks for everyone’s suggestions. Here’s what I’ve done (and it works):
Python script:
#!/usr/bin/env python
"""Set Spheramid underlight to brightness in command line parameter."""
import os
import sys
try:
value = int(sys.argv[1])
if value < 0:
value = 0
elif value > 100:
value = 100
except (ValueError, IndexError):
value = 0
os.system("mosquitto_pub -m '{{\"brightness\": {}}}' -t '$hardware/status/reset' -h ninjasphere.local".format(value))
The only thing I don’t have is an accurate read of its brightness, but I don’t think it provides that, so it’s no problem.
So now I can turn the light on and off, and I can adjust the slider to set its brightness. All good.