Hi all
I’m trying to achieve a Shelly Vintage integration directly in the light.yaml without HACS. Actually, 95% of the integration is working properly. The only thing, if I press the Bulb-Button in LoveLance it tells me that the brightness is not defined. So if the bulp is off and I just slide the brightness from 0% to lets say 30%, the bulp turns on with the proper brightness.
With that knowing, I tried to adjust the configuration on “command_on_template” to handle the brightness atttribute if not defined and set it directly. If it is there just go on.
Unfortunately, as soon as I put multiline on command_on_template the brightness slider does not work at all. I only can turn the light off. Configuration doesn’t bring any error.
Does anybody has any idea what I’m doing wrong here?
Here is the whole configuration:
NOT WORKING
- platform: mqtt
schema: template
name: "Test Light"
state_topic: "shellies/ShellyVintage-6F73CB/light/0/status"
state_template: >-
{% set bulb = value_json.ison %}
{% if bulb == true %}
on
{% else %}
off
{% endif %}
brightness_template: "{{ value_json.brightness | float | multiply(2.55) | round(0) }}"
command_topic: "shellies/ShellyVintage-6F73CB/light/0/set"
command_on_template: >-
{% if brightness is defined %}
'{"turn":"on", "brightness":{{brightness | float | multiply(0.3922) | round(0)}}}'
{% else %}
'{"turn":"on", "brightness":30}'
{% endif %}
command_off_template: '{"turn":"off", "brightness":0}'
Thank you a lot