RGB for ninja block eyes

Hi folks,
Newbie here, so please excuse me if the solution is obvious but I’m hitting the wall with this issue :slight_smile:

I have a proper Home Assistant installation working with a ninja block using this ninja cape mqtt bridge (https://github.com/perrin7/ninjacape-mqtt-bridge), so temperature, humidity, buttons and plugs works fine but I’m not able to configure the ninja eyes…

The things is, I need to send the rgb values in hexadecimal as RRGGBB (so FF0000 for red), so I’ve created a mqtt_template entry as:

  platform: mqtt_template
  name: "Ninja Status"
  state_topic: "ninjaCape/input/1007"
  command_topic: "ninjaCape/output/1007"
  command_off_template: "000000"
  command_on_template: "FFFFFF"
  red_template: '{{ value[0] | int(base=16) }}'
  green_template: '{{ value[1] | int(base=16) }}'
  blue_template: '{{ value[2] | int(base=16) }}'

So, while turn them on and off works, color change fails as:

2017-07-25 16:37:47 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback async_subscribe.<locals>.async_mqtt_topic_subscriber('ninjaCape/input/999', b'FFFFFF', 0) at /srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/mqtt/__init__.py:207
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 226, 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 245, in async_run_job
target(*args)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/light/mqtt_template.py", line 156, in state_received
async_render_with_possible_json_value(payload)
AttributeError: 'NoneType' object has no attribute 'async_render_with_possible_json_value'

So, what I think it is needed is to modify the value hass send to the mqtt so instead is an array of decimals [ red, green, blue] it is an hexadecimal number composed by those numbers… but it is obviously not what I’m doing :smiley:

Doing it manually using mosquitto works fine:

mosquitto_pub -d -h 192.168.1.2 -t "ninjaCape/output/1007" -m "FF00FF" -V mqttv311

Using the template editor, this seems to work to extract the values:

{% set value="FF00FF" %}
{{ value[4:6] | int(base=16) }}

I’ve modified the light section as:

  red_template: '{{ value[0:2] | int(base=16) }}'
  green_template: '{{ value[2:4] | int(base=16) }}'
  blue_template: '{{ value[4:6] | int(base=16) }}'

But it doesn’t work either.

Any clue?