I’m pretty new to home assistant and Jinja. I have some stuff running in OpenHAB for quiet a bit and now I’m trying to move to home assistant. I use some actors I built myself. They are accessible via MQTT. One of them I’m currently struggling with is a RGB LED strip controller. To set (and get its current state) I have an RGB topic. The topic receives and transmits the pure RGB hex value, e.g. cc00ff.
I’m not using JSON as I’m kind of an old-school emebedded guy trying to keep everything simple and with as less overhead as possible, so I didn’t use JSON here. But actually with my zero-knowledge of Jinja I have no idea how to construct a template parsing (and sending) the RGB data to/from my actor.
Do I even have a chance to do so? Or should I consider changing my data format, which I’m not too comfortable with right now.
Have the same problem. As sending non hex data to mys node will have a lag where light first switches green than blue than red channels. And with sending HEX data everything is done on the node. So any solution for this?
import java.awt.Color
rule "Set bed_lgt_RGB value"
when
Item bed_lgt_RGB changed
then
val HSBType hsb = bed_lgt_RGB.state as HSBType
var Color color = Color::getHSBColor(hsb.hue.floatValue / 360, hsb.saturation.floatValue / 100, hsb.brightness.floatValue / 100)
val String rgb = String::format("%1$02x%2$02x%3$02x", color.red, color.green, color.blue)
publish("mqt", "mygateway1-in/36/0/1/0/40", rgb)
end
2017-09-25 09:42:05 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback async_subscribe.<locals>.async_mqtt_topic_subscriber('ninjaCape/input/1007', b'F513FF', 0) at /srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/mqtt/__init__.py:213
Traceback (most recent call last):
File "/usr/lib/python3.4/asyncio/events.py", line 120, in _run
self._callback(*self._args)
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/mqtt/__init__.py", line 232, in async_mqtt_topic_subscriber
hass.async_run_job(msg_callback, dp_topic, payload, dp_qos)
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/core.py", line 247, in async_run_job
target(*args)
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/light/mqtt.py", line 252, in rgb_received
templates[CONF_RGB](payload).split(',')]
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/light/mqtt.py", line 251, in <listcomp>
self._rgb = [int(val) for val in
ValueError: invalid literal for int() with base 10: 'F513FF'
As far as I see you’re playing with Sonoff Tasmota by Theo Arendst. I have made a small modifications to standard MQTT light component to work with led strips on Tasmota. Here it is: https://github.com/ardeus-ua/ha-tasmota