Skip to content

Commit

Permalink
fix(hass): inovelli lzw42 multi color bulb discovery update (#690)
Browse files Browse the repository at this point in the history
* Update HASS discovery for LZW42

* Remove needless casts.

* Too greedy on removing casts to int...

* Change to single quotes.

* Lint fixes.

Co-authored-by: Daniel Lando <[email protected]>
  • Loading branch information
DanielWinks and robertsLando authored Feb 24, 2021
1 parent 2a803da commit 9669cce
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions hass/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,28 +206,37 @@ module.exports = {
{
type: 'light',
object_id: 'rgbw_bulb',
values: ['38-0-currentValue', '38-0-targetValue', '51-1-0'], // FIXME: Handle color CC
values: [
'38-0-currentValue',
'38-0-targetValue',
'51-0-currentColor',
'51-0-targetColor'
],
discovery_payload: {
state_topic: '38-0-currentValue',
command_topic: '38-0-targetValue',
on_command_type: 'brightness',
brightness_state_topic: '38-0-currentValue',
brightness_command_topic: '38-0-targetValue',
state_value_template: '{{ "OFF" if value_json.value == 0 else "ON" }}',
brightness_value_template: '{{ (value_json.value) | round(0) }}',
state_value_template: '{{ "on" if value_json.value|int > 0 else "0" }}',
brightness_value_template: '{{ (value_json.value|int) | round(0) }}',
brightness_scale: '99',
color_temp_state_topic: '51-1-0',
color_temp_state_topic: '51-0-currentColor',
color_temp_command_template:
"{{ '#%02x%02x%02x%02x%02x' | format(0, 0, 0, (0.7349 * (value - 153)) | round(0), 255 - (0.7349 * (value - 153)) | round(0))}}",
color_temp_command_topic: '51-1-0',
"{{ {'warmWhite': ((0.7349 * (value - 153))|round(0)), 'coldWhite': (255 - (0.7349 * (value - 153))|round(0)), 'red': 255, 'green': 255, 'blue': 255}|to_json }}",
color_temp_command_topic: '51-0-targetColor',
color_temp_value_template:
'{{ (((value_json.value[7:9] | int(0, 16)) / 0.7349 ) | round(0)) + 153 }}',
"{{ '%03d%03d' | format((value_json.value.warmWhite), (value_json.value.coldWhite)) }}",
rgb_command_template:
"{{'#%02x%02x%02x%02x%02x' | format(red, green, blue,0,0)}}",
rgb_command_topic: '51-1-0',
rgb_state_topic: '51-1-0',
"{{ {'warmWhite': 0, 'coldWhite': 0, 'red': red, 'green': green, 'blue': blue}|to_json }}",
rgb_command_topic: '51-0-targetColor',
rgb_state_topic: '51-0-currentColor',
rgb_value_template:
'{{ value_json.value[1:3] | int(0, 16) }},{{ value_json.value[3:5] | int(0, 16) }},{{ value_json.value[5:7] | int(0, 16) }}'
'{{ value_json.value.red }},{{ value_json.value.green }},{{ value_json.value.blue }}',
min_mireds: 153,
max_mireds: 500,
payload_on: 'on',
payload_off: '0'
}
}
],
Expand Down

0 comments on commit 9669cce

Please sign in to comment.