Skip to content

Instantly share code, notes, and snippets.

@amosyuen
Last active March 2, 2024 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save amosyuen/d90427dcba5ae336b48da5f81e744fd7 to your computer and use it in GitHub Desktop.
Save amosyuen/d90427dcba5ae336b48da5f81e744fd7 to your computer and use it in GitHub Desktop.
Home Assistant Z2M Configure Inovelli Blue Script
configure_inovelli_blue:
description: Configure Inovelli Blue Dimmer
mode: restart
fields:
device:
name: Device
description: List of inovelli devices. Defaults to all devices.
selector:
device:
integration: mqtt
manufacturer: Inovelli
model: Inovelli 2-in-1 switch + dimmer (VZM31-SN)
multiple: true
sequence:
- alias: Coerce device param to array or default to all inovelli dimmers
variables:
device: >-
{%- set device = iif(device is string, [device], device) -%}
{%- if (device | length > 0) -%}
{{ device }}
{%- else -%}
{%- set ns = namespace(devices=[]) -%}
{%- for device_id in integration_entities('mqtt') | map('device_id') | reject('eq', None) | unique -%}
{%- if (device_attr(device_id, 'model') == 'Inovelli 2-in-1 switch + dimmer (VZM31-SN)') -%}
{%- set ns.devices = ns.devices + [device_id] -%}
{%- endif -%}
{%- endfor -%}
{{ ns.devices }}
{%- endif -%}
- alias: Find entities to disable
variables:
disable_entities: >-
{%- set ns = namespace(entities=[]) -%}
{%- for d in device -%}
{%- set ns.entities = ns.entities
+ (device_entities(d)
| reject('match', '^(light|update)\..+')
| reject('match', '^sensor\..+_action')
| list) -%}
{%- endfor -%}
{{ ns.entities }}
- if:
- condition: template
value_template: "{{ disable_entities | length > 0}}"
then:
- service: system_log.write
data:
level: warning
message: >-
Should disable inovelli blue entities in Z2M config similar to
https://gist.github.com/amosyuen/a913469965a579d0cc2a1eaaaf544945.
Entities: {{ disable_entities }}
- alias: Loop devices
repeat:
for_each: "{{ device }}"
sequence:
- alias: Set device name
variables:
name: "{{ device_attr(repeat.item, 'name') }}"
- alias: Disable power and energy reporting
repeat:
# "maximum_report_interval": 65535 (non-string value) means delete
for_each:
- |
{
"id": "{{ name }}/1",
"cluster": "haElectricalMeasurement",
"attribute": "activePower",
"minimum_report_interval": "1",
"maximum_report_interval": 65535,
"reportable_change": "32767"
}
- |
{
"id": "{{ name }}/1",
"cluster": "seMetering",
"attribute": "currentSummDelivered",
"minimum_report_interval": "1",
"maximum_report_interval": 65535,
"reportable_change": "32767"
}
sequence:
- service: mqtt.publish
data:
topic: "zigbee2mqtt/bridge/request/device/configure_reporting"
payload: "{{ repeat.item }}"
- alias: Wait for Z2M to process messages to avoid overloading
delay:
seconds: 1
- alias: Configure device
repeat:
for_each:
- '"activeEnergyReports": 0'
- '"activePowerReports": 0'
- '"autoTimerOff": 0'
- '"buttonDelay": "100ms"'
- '"defaultLed1ColorWhenOff": 255'
- '"defaultLed1ColorWhenOn": 255'
- '"defaultLed1IntensityWhenOff": 101'
- '"defaultLed1IntensityWhenOn": 101'
- '"defaultLed2ColorWhenOff": 255'
- '"defaultLed2ColorWhenOn": 255'
- '"defaultLed2IntensityWhenOff": 101'
- '"defaultLed2IntensityWhenOn": 101'
- '"defaultLed3ColorWhenOff": 255'
- '"defaultLed3ColorWhenOn": 255'
- '"defaultLed3IntensityWhenOff": 101'
- '"defaultLed3IntensityWhenOn": 101'
- '"defaultLed4ColorWhenOff": 255'
- '"defaultLed4ColorWhenOn": 255'
- '"defaultLed4IntensityWhenOff": 101'
- '"defaultLed4IntensityWhenOn": 101'
- '"defaultLed5ColorWhenOff": 255'
- '"defaultLed5ColorWhenOn": 255'
- '"defaultLed5IntensityWhenOff": 101'
- '"defaultLed5IntensityWhenOn": 101'
- '"defaultLed6ColorWhenOff": 255'
- '"defaultLed6ColorWhenOn": 255'
- '"defaultLed6IntensityWhenOff": 101'
- '"defaultLed6IntensityWhenOn": 101'
- '"defaultLed7ColorWhenOff": 255'
- '"defaultLed7ColorWhenOn": 255'
- '"defaultLed7IntensityWhenOff": 101'
- '"defaultLed7IntensityWhenOn": 101'
- '"defaultLevelLocal": 255'
- '"defaultLevelRemote": 255'
- '"dimmingSpeedDownLocal": 10'
- '"dimmingSpeedDownRemote": 0'
- '"dimmingSpeedUpLocal": 25'
- '"dimmingSpeedUpRemote": 0'
- '"doubleTapClearNotifications": "Disabled"'
- '"doubleTapUpForFullBrightness": "Button Press Event + Set Load to 100%"'
- '"firmwareUpdateInProgressIndicator": "Enabled"'
- '"invertSwitch": "No"'
- '"ledIntensityWhenOff": 1'
- '"ledIntensityWhenOn": 33'
- '"loadLevelIndicatorTimeout": "Stay On"'
- '"localProtection": "Disabled"'
- '"onOffLedMode": "All"'
- '"outputMode": "Dimmer"'
- '"periodicPowerAndEnergyReports": 32767'
- '"rampRateOffToOnLocal": 5'
- '"rampRateOffToOnRemote": 5'
- '"rampRateOnToOffLocal": 10'
- '"rampRateOnToOffRemote": 10'
- '"relayClick": "Disabled"'
- '"stateAfterPowerRestored": 0'
sequence:
- service: mqtt.publish
data:
topic: "zigbee2mqtt/{{ name }}/set"
payload: "{ {{ repeat.item }} }"
- alias: Wait for Z2M to process messages to avoid overloading
delay:
seconds: 1
@ZetaWaves
Copy link

This no longer functions in 2024.2.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment