# ezlo_devices.yaml
#
# Copyright (C) 2021,2022 Kedron Holdings LLC, All Rights Reserved
# This file is part of Reactor.
#
# *** IMPORTANT ***
# This is a system file. DO NOT place overrides or make modifications here.
# You can add or override implementation section items by specifying them
# in local_ezlo_devices.yaml in your site configuration.
---
version: 25191
revision: 1
format: 1
copyright: Copyright (C) 2020-2025 Kedron Holdings LLC, All Rights Reserved

# Default API version number for methods used in this file (string)
default_api_version: "1.0"

# The implementation section describes how each capability is mapped from
# eZLO's model into the Reactor model. The attributes subsection of each
# capability must contain a declaration for each attribute described in
# the system definition of the capability. The actions section defines how
# each capability's actions is mapped to an eZLO method, and how its data
# is mapped from the Reactor action's parameters and data. The default
# method (i.e. if not specified) is hub.item.value.set.
# See the docs for more information.
implementation:
  power_switch:
    attributes:
      state:
        item: switch
    actions:
      'on':
        item: switch
        value: true
      'off':
        item: switch
        value: false
      'set':
        item: switch
        value_expr: "bool( parameters.state )"
  toggle:
    attributes: false  # has none
    actions:
      toggle:
        item: switch
        value_expr: "! entity.attributes.power_switch.state"
  dimming:
    attributes:
      level:
        item: dimmer
        value_expr: "value / 100"
    actions:
      set:
        item: dimmer
        value_expr: "min(100,max(0,floor(parameters.level*100+0.5)))"
      up:
        method: "hub.item.value.percent.apply"
        item: dimmer
        parameters:
          percent:
            value_expr: "floor( ( entity.attributes.dimming.step ?? 0.1 ) * 100 + 0.5 )"
      down:
        method: "hub.item.value.percent.apply"
        item: dimmer
        parameters:
          percent:
            value_expr: "-floor( ( entity.attributes.dimming.step ?? 0.1 ) * 100 + 0.5 )"
  rgb_color:
    attributes:
      red:
        item: rgbcolor
        value_expr: value?.red
      green:
        item: rgbcolor
        value_expr: value?.green
      blue:
        item: rgbcolor
        value_expr: value?.blue
    actions:
      set:
        item: rgbcolor
        value_expr: "{ 'red':(parameters.value>>16)&255, 'green':(parameters.value>>8)&255, 'blue':parameters.value&255 }"
      set_rgb:
        item: rgbcolor
        value_expr: "{ 'red':parameters.red, 'green':parameters.green, 'blue':parameters.blue }"
  color_temperature:
    attributes:
      value:
        item: rgbcolor
        value_expr: >
          c=value?.cwhite ?# 0, w=value?.wwhite,
          c > 0 ?
            floor( 5500 + c * 3500 / 255 ) :
            ( isnull(w) ? null : floor( 2000 + w * 3500 / 255 ) )
    actions:
      set:
        item: rgbcolor
        value_expr: >
          parameters.value > 5500 ?
            { wwhite: 0, cwhite: floor( ( parameters.value - 5500 ) / 3500 * 255 ) } :
            { cwhite: 0, wwhite: floor( ( parameters.value - 2000 ) / 3500 * 255 ) }
  lock:
    attributes:
      state:
        item: door_lock
        value_expr: "'secured' == value"
    actions:
      lock:
        item: door_lock
        value: secured
      unlock:
        item: door_lock
        value: unsecured
      set:
        item: door_lock
        value_expr: "bool( parameters.state ) ? 'secured' : 'unsecured'"
  passage:
    attributes:
      state:
        item: barrier
        value_expr: "'barrier_closed' == value"
    actions:
      close:
        item: barrier
        value: barrier_closed
      open:
        item: barrier
        value: barrier_opened
      set:
        item: barrier
        value_expr: "bool( parameters.state ) ? 'barrier_closed' : 'barrier_opened'"
  cover:
    attributes:
      state:
        item: dimmer
        value_expr: "( value ?# 0 ) > 0 ? 'open' : 'closed'"
    actions:
      open:
        item: dimmer
        value: 100
      close:
        item: dimmer
        value: 0
      stop: false
  position:
    attributes:
      value:
        item: dimmer
        value_expr: value / 100
    actions:
      increase:
        item: dimmer
        value_expr: "min( 1, max( 0, ( entity.attributes.position.value + parameters.amount ) ) ) * 100"
      decrease:
        item: dimmer
        value_expr: "min( 1, max( 0, ( entity.attributes.position.value - parameters.amount ) ) ) * 100"
      relative:
        item: dimmer
        value_expr: "min( 1, max( 0, ( entity.attributes.position.value + parameters.amount ) ) ) * 100"
      set:
        item: dimmer
        value_expr: "min( 1, max( 0, parameters.value ?# 0 ) ) * 100"
  av_transport:
    attributes:
      state:
        item: sound_playback
        value_expr: '({"stop":"STOPPED","play":"PLAYING"})[value] ?? value'
      current_track: null
      current_title: null
      current_artist: null
      current_album: null
      album_art: null
    actions:
      stop:
        item: sound_playback
        value: stop
      pause:
        item: sound_playback
        value: stop
      play:
        item: sound_playback
        value: play
      rewind: false
      fast_forward: false
  volume:
    attributes:
      level:
        item: sound_volume
        value_expr: value / 100
    actions:
      set:
        item: sound_volume
        value_expr: 'min(100,max(0,floor( parameters.level*100 + 0.5 )))'
      increase:
        method: "hub.item.value.percent.apply"
        item: sound_volume
        parameters:
          percent: 10
      decrease:
        method: "hub.item.value.percent.apply"
        item: sound_volume
        parameters:
          percent: -10
      relative:
        item: sound_volume
        value_expr: 'floor( max( 0, min( 1, entity.volume.level + parameters.amount ) ) )'
      set_db: false
  muting:
    attributes:
      state:
        item: sounding_mode
        value_expr: '({"silent":true,"audible":false,"unknown":null})[value]'
    actions:
      mute:
        item: sounding_mode
        value: true
      unmute:
        item: sounding_mode
        value: false
      toggle:
        item: sounding_mode
        value_expr: '! entity.attributes.muting.state'
      set:
        item: sounding_mode
        value_expr: 'bool( parameters.muting )'
  hvac_control:
    attributes:
      mode:
        item: thermostat_mode
      state:
        item: thermostat_operating_state
    actions:
      set_mode:
        item: thermostat_mode
        parameter: mode
  hvac_heating_unit:
    attributes:
      state:
        item: thermostat_operating_state
        value_expr: '"heating" === value'
      setpoint:
        item: thermostat_setpoint_heating
      units:
        item: thermostat_setpoint_heating
        value_expr: >
          ( ({'celsius':'C','fahrenheit':'F','kelvin':'K'})[item?.scale] ?? item?.scale ) ??
            system.attributes.x_ezlo_sys?.temperature_unit
    actions:
      set_setpoint:
        item: thermostat_setpoint_heating
        parameter: setpoint
  hvac_cooling_unit:
    attributes:
      state:
        item: thermostat_operating_state
        value_expr: '"cooling" === value'
      setpoint:
        item: thermostat_setpoint_cooling
      units:
        item: thermostat_setpoint_cooling
        value_expr: >
          ( ({'celsius':'C','fahrenheit':'F','kelvin':'K'})[item?.scale] ?? item?.scale ) ??
            system.attributes.x_ezlo_sys?.temperature_unit
    actions:
      set_setpoint:
        item: thermostat_setpoint_cooling
        parameter: setpoint
  hvac_blower_unit:
    attributes:
      mode:
        item: thermostat_fan_mode
        value_expr: >
          ({  "auto_low":"auto",
              "auto_high":"auto",
              "auto_medium":"auto",
              "on":"continuous",
              "fanmode_off":"off",
              "low":"low",
              "medium":"medium",
              "high":"high",
              "circulation":"periodic",
              "humidity_circulation":"periodic",
              "left_and_right":"on",
              "up_and_down":"on",
              "quiet":"low",
              "auto":"auto"
          })[value] ?? value
      state:
        item: thermostat_fan_state
        value_expr: 'value != "idle_off"'
      filter_change:
        item: maintenance_state
        value_expr: '( value ?? "OK" )!= "OK"'
    actions:
      set_mode:
        item: thermostat_fan_mode
        # on, off, auto, low, medium, high are same on Ezlo as MSR
        value_expr: >
          ({  "continuous": "on",
              "periodic": "circulation",
              "off": "off"
          })[ parameters.mode ] ?? parameters.mode
  tamper:
    attributes:
      state:
        item: tampering_cover_alarm
        value_expr: '({"tampering_cover":true,"no_tampering_cover":false,"unknown":null})[value]'
  door_sensor:
    attributes:
      state:
        item: dw_state
        value_expr: '({"dw_is_closed":false,"dw_is_opened":true,"unknown":null})[value]'
  motion_sensor:
    attributes:
      state:
        item: motion  # value is already boolean
  leak_detector:
    attributes:
      state:
        item: water_leak_alarm
        value_expr: '({"no_water_leak":false,"water_leak_detected":true})[value]'
  glass_break_detector:
    attributes:
      state:
        item: glass_breakage_alarm
        value_expr: '({"no_glass_breakage":false,"glass_breakage":true})[value]'
  heat_detector:
    attributes:
      state:
        item: heat_alarm
        value_expr: 'value == "unknown" ? null : ( value != "heat_ok" )'
  smoke_detector:
    attributes:
      state:
        item: smoke_alarm
        value_expr: '({"no_smoke":false,"smoke_detected":true})[value]'
  co_detector:
    attributes:
      state:
        item: co2_alarm
        value_expr: '({"no_co2":false,"co2_detected":true})[value]'
  co2_detector:
    attributes:
      state:
        item: co2_alarm
        value_expr: '({"no_co2":false,"co2_detected":true})[value]'
  gas_detector:
    attributes:
      state:
        item: gas_alarm
        value_expr: '({"no_gas":false,"combustible_gas_detected":true,"toxic_gas_detected":true})[value]'
  temperature_sensor:
    attributes:
      value:
        item: temp
      units:
        item: temp
        value_expr: "({'celsius':'C','fahrenheit':'F','kelvin':'K'})[item?.scale] ?? system.attributes.x_ezlo_sys.temperature_unit"
  humidity_sensor:
    attributes:
      value:
        item: humidity
      units:
        item: humidity
        value_expr: item.scale
        map:
          percent: '%'
  light_sensor:
    attributes:
      value:
        item: lux
      units:
        item: lux
        value_expr: item?.scale
        map:
          percent: '%'
          # lux is lux
  uv_sensor:
    attributes:
      value:
        item: ultraviolet
      units:
        item: ultraviolet
        value_expr: "item?.scale"
        map:
          uv_index: 'UVI'
  voltage_sensor:
    attributes:
      value:
        item: voltage
      units:
        item: voltage
        value_expr: "item?.scale"
        map:
          volt: 'V'
          milli_volt: 'mV'
  current_sensor:
    attributes:
      value:
        item: current
      units:
        item: current
        value_expr: "item?.scale"
        map:
          ampere: 'A'
          milli_ampere: 'mA'
  power_sensor:
    attributes:
      value:
        item: power
      units:
        item: power
        value_expr: "item?.scale"
        map:
          watt: 'W'
          kilo_watt: 'KW'
          btu_per_hour: 'BTU/h'
  "power_sensor#electric_meter_watt":
    attributes:
      value:
        item: electric_meter_watt
      units:
        item: electric_meter_watt
        value_expr: "item?.scale"
        map:
          watt: 'W'
          kilo_watt: 'KW'
  "energy_sensor#electric_meter_kwh":
    attributes:
      value:
        item: electric_meter_kwh
      units:
        item: electric_meter_kwh
        value_expr: "item?.scale"
        map:
          wat_hour: 'Wh'
          kilo_watt_hour: 'KWh'
  battery_power:
    attributes:
      level:
        item: battery
        value_expr: value / 100
      since:
        value_expr: "time()"
  arming:
    attributes:
      state:
        value_expr: fields.armed
    actions:
      arm:
        method: "hub.device.armed.set"
        parameters:
          armed: true
      disarm:
        method: "hub.device.armed.set"
        parameters:
          armed: false
  ir_remote:
    attributes: false
    actions:
      learn:
        item: learn_ir_code
        value_expr: value ?# 0
      delete: false
      send: false
      send_codes:
        function: action_send_ir_codes
  rf_remote:
    attributes: false
    actions:
      learn:
        item: learn_rf_code
        value_expr: value ?# 0
      delete: false
      send: false
      send_codes:
        function: action_send_rf_codes
      detect:
        item: sweep_rf
        value_expr: value ?# 0
  button:
    attributes:
      state:
        item: button_state
        value_expr: "item.value.button_state"
        map:
          "idle": null
          "press_1_time": "single"
          "released": "release"
          "held_down": "hold"
          "press_2_times": "double"
        update_only: true
      since:
        item: button_state  # bind to state, even though not using value (i.e. value is only trigger)
        value_expr: "time()"
        update_only: true
    actions:
      press: false
      single:
        item: button_state
        value: press_1_time
      double:
        item: button_state
        value: press_2_times
      hold:
        item: button_state
        value: held_down
      release:
        item: button_state
        value: released
      long: false
  script:
    attributes:
      runnable: null
    actions:
      run:
        method: "hub.scenes.run"
        parameters:
          sceneId:
            entity: attributes.x_ezlo_object.id
  sys_system:
    attributes: false
    actions: {}
  zwave_device:
    attributes:
      node_id:
        value_expr: "int(fields.info?['zwave.node'])"
      failed:
        value_expr: "!fields.reachable"
      capabilities: null
      manufacturer_info:
        value_expr: "[fields.info?.manufacturer,fields.info?.model,null]"
      version_info: null
    actions:
      poll:
        method: "hub.device.check"
        id_source: object
        parameters: {}
  zwave_network:
    attributes:
      state: true  # assumed
    actions:
      send_data: false  # no implementation???
      start_include:
        method: "hub.extensions.plugin.run"
        id_source: none
        parameters:
          script: "HUB:zwave/scripts/start_include"
      stop_include:
        method: "hub.extensions.plugin.run"
        id_source: none
        parameters:
          script: "HUB:zwave/scripts/stop_include"
      start_exclude:
        method: "hub.extensions.plugin.run"
        id_source: none
        parameters:
          script: "HUB:zwave/scripts/start_exclude"
      stop_exclude:
        method: "hub.extensions.plugin.run"
        id_source: none
        parameters:
          script: "HUB:zwave/scripts/stop_exclude"
      set_configuration_value: false
  x_ezlo_housemode:
    attributes: false
    actions:
      set:
        method: "hub.modes.switch"
        id_source: none
        parameters:
          modeId:
            value_expr: "str( parameters?.mode_id ?? 1 )"
      set_mode:
        method: "hub.modes.switch"
        id_source: none
        parameters:
          name:
            value_expr: "str( parameters?.mode_name ?? 'home' )"
      cancel_set:
        method: "hub.modes.cancel_switch"
        id_source: none
        parameters: {}
  battery_maintenance:
    attributes:
      charging:
        # Ref: https://api.ezlo.com/devices/item_enums/index.html#battery-maintenance-state
        item: battery_charging_state
        optional: true
        value_expr: '({"in_progress":true,"no_charging":false,"unknown":null})[value]'
      replace:
        # Ref: https://api.ezlo.com/devices/item_enums/index.html#battery-maintenance-state
        item: battery_maintenance_state
        optional: true
        value_expr: 'value == "unknown" ? null : ( value != "battery_maintenance_ok" )'
      rechargeable: null
  x_ezlo_battery_state:
    attributes:
      charging:
        # Ref: https://api.ezlo.com/devices/item_enums/index.html#battery-maintenance-state
        item: battery_charging_state
        optional: true
        value_expr: '({"in_progress":true,"no_charging":false,"unknown":null})[value]'
      maintenance_required:
        # Ref: https://api.ezlo.com/devices/item_enums/index.html#battery-maintenance-state
        item: battery_maintenance_state
        optional: true
        value_expr: 'value == "unknown" ? null : ( value != "battery_maintenance_ok" )'
  x_ezlo_device:
    attributes:
      parent:
        field: parentDeviceId
      room:
        field: roomId
      category:
        field: category
      subcategory:
        field: subcategory
      ready:
        field: ready
      status:
        field: status
      reachable:
        field: reachable
      battery_powered:
        field: batteryPowered
      type_id:
        field: deviceTypeId
      manufacturer:
        field: info.manufacturer
      model:
        field: info.model
    actions:
      set_name:
        method: "hub.device.name.set"
        parameters:
          name:
            parameter: name
      set_room:
        method: "hub.device.room.set"
        parameters:
          roomId:
            parameter: room_id
      status_check:
        method: "hub.device.status.check"
      device_check:
        method: "hub.device.check"
      set_item_value:
        function: action_set_item_value
  x_ezlo_room:
    attributes: false
    actions:
      set_name:
        method: "hub.room.name.set"
        parameters:
          name:
            parameter: name
  x_ezlo_sys:
    attributes: false
    actions:
      runlua:
        method: "hub.extensions.plugin.run"
        id_source: none
        parameters:
          code:
            value_expr: btoa( parameters.lua ?? "--" )
      restart:
        method: "hub.reboot"
        id_source: none
      set_setting:
        method: "hub.setting.value.set"
        id_source: none
        parameters:
          name:
            parameter: name
          value:
            value_expr: >
              parameters.type == "int" ? int( parameters.value ) :
                ( parameters.type == "bool" ? bool( parameters.value ) :
                  ( parameters.type == "real" ? float( parameters.value ) :
                    ( parameters.type == "json" ? parseJSON( parameters.value ) : parameters.value )
                  )
                )

  x_ezlo_object:
    attributes: false  # all attributes are defined by class code

# The mapping section describes how EzloController maps native devices and items
# into Reactor entities and attributes. The first matching rule controls. Again,
# DO NOT make local overrides/mods here. See the note at the top of this file
# for how to make your site-specific mods.
#
# The section is an array of objects. The "match" key of each objects is used to
# match data from the device info response. Each criterion is separated by ";".
# The criteria are "field=value" format. The value may be a regular expression
# (case-insensitive test, always) by enclosing in // (e.g. /regexp/ ). If the
# criterion begins with an "=", the entire string that follows is assumed to be
# an expression that must resolve to a boolean value, where true indicates a
# match (e.g. "=fields.info?.protocol=='zwave'")
mapping:
  - match: "category=dimmable_light"
    type: Light
    capabilities:
      - dimming
      # color capabilities may be added by presence of rgbcolor item (extensions)
    primary_attribute: dimming.level
  - match: "category=switch"
    type: Switch
    capabilities:
      - power_switch
      - toggle
    primary_attribute: power_switch.state
  - match: "category=garage_door"
    capabilities:
      - passage
    primary_attribute: passage.state
  - match: "category=security_sensor;subcategory=door"
    type: SecuritySensor
    capabilities:
      - door_sensor
      - arming
    primary_attribute: door_sensor.state
  - match: "category=security_sensor;subcategory=leak"
    type: SecuritySensor
    capabilities:
      - leak_detector
      - arming
    primary_attribute: leak_detector.state
  - match: "category=security_sensor;subcategory=motion"
    type: SecuritySensor
    capabilities:
      - motion_sensor
      - arming
    primary_attribute: motion_sensor.state
  - match: "category=generic_sensor;subcategory=motion"
    type: SecuritySensor
    capabilities:
      - motion_sensor
    primary_attribute: motion_sensor.state
  - match: "category=security_sensor;subcategory=smoke"
    type: SecuritySensor
    capabilities:
      - smoke_detector
      - arming
    primary_attribute: smoke_detector.state
  - match: "category=security_sensor;subcategory=co"
    type: SecuritySensor
    capabilities:
      - co_detector
      - arming
    primary_attribute: co_detector.state
  - match: "category=security_sensor;subcategory=glass"
    type: SecuritySensor
    capabilities:
      - glass_break_detector
      - arming
    primary_attribute: glass_break_detector.state
  - match: "category=security_sensor;subcategory=co2"
    type: SecuritySensor
    capabilities:
      - co2_detector
      - arming
    primary_attribute: gas_detector.state
  - match: "category=security_sensor;subcategory=gas"
    type: SecuritySensor
    capabilities:
      - gas_detector
      - arming
    primary_attribute: gas_detector.state
  - match: "category=security_sensor;subcategory=heat"
    type: SecuritySensor
    capabilities:
      - heat_detector
      - arming
    primary_attribute: heat_detector.state
  - match: "category=hvac;subcategory=heater"
    capabilities:
      - hvac_control
      - hvac_heating_unit
      - hvac_blower_unit
    primary_attribute: hvac_control.state
  - match: "category=hvac;subcategory=cooler"
    capabilities:
      - hvac_control
      - hvac_cooling_unit
      - hvac_blower_unit
    primary_attribute: hvac_control.state
  - match: "category=hvac"
    capabilities:
      - hvac_control
      - hvac_heating_unit
      - hvac_cooling_unit
      - hvac_blower_unit
    primary_attribute: hvac_control.state
  # camera?
  - match: "category=door_lock"
    type: Lock
    capabilities:
      - lock
      #- keypad
      #- lock_codes
    primary_attribute: lock.state
  - match: "category=window_cov"
    type: Cover
    capabilities:
      - cover
      - position
    primary_attribute: cover.state
  - match: "category=ir_tx;deviceTypeId=broadlink_rm_pro"
    # Broadlink RM Pro handles both IR and RF
    capabilities:
      - ir_remote
      - rf_remote
  - match: "category=ir_tx"
    capabilities:
      - ir_remote
      - power_switch
    primary_attribute: power_switch.state
  - match: "category=generic_sensor"
    type: ValueSensor
    capabilities:
      - value_sensor
    primary_attribute: value_sensor.value
  - match: "category=scene_controller"
    capabilities:
      - zwave_scene_controller
  - match: "category=remote_control"
    capabilities:
      # remote controls (a form of scene controller) will have at least one button, so handle that here.
      # others will be handled by extensions (hopefully)
      - button
    primary_attribute: button.state
  - match: "category=av"
    capabilities:
      - av_transport
      - media_navigation
      - volume
      - muting
      - av_repeat
      - media_source
      - media_output
      - tuner
    primary_attribute: av_transport.state
  - match: "category=humidity"
    type: ValueSensor
    capabilities:
      - humidity_sensor
    primary_attribute: humidity_sensor.value
  - match: "category=temperature"
    type: ValueSensor
    capabilities:
      - temperature_sensor
    primary_attribute: temperature_sensor.value
  - match: "category=light_sensor"
    type: ValueSensor
    capabilities:
      - light_sensor
    primary_attribute: light_sensor.value
  - match: "category=uv_sensor"
    type: ValueSensor
    capabilities:
      - uv_sensor
    primary_attribute: uv_sensor.value
  - match: "category=voltage_sensor"
    type: ValueSensor
    capabilities:
      - voltage_sensor
    primary_attribute: voltage_sensor.value
  - match: "category=level_sensor;subcategory=current"
    type: ValueSensor
    capabilities:
      - current_sensor
    primary_attribute: current_sensor.value
  - match: "category=level_sensor;subcategory=power"  # ??? missing/unknown/undoc, this is assumed
    type: ValueSensor
    capabilities:
      - power_sensor
    primary_attribute: power_sensor.value
  - match: "category=level_sensor;subcategory=seismicity"
    type: ValueSensor
    capabilities:
      - capability: value_sensor
        attributes:
          value:
            item: seismic_intensity
          units:
            item: seismic_intensity
            value_expr: "item?.scale"
    primary_attribute: value_sensor.value
  - match: "category=level_sensor;subcategory=sound"
    type: ValueSensor
    capabilities:
      - capability: value_sensor
        attributes:
          value:
            item: loudness
          units:
            item: loudness
            value_expr: "item?.scale"
    primary_attribute: value_sensor.value
  - match: "category=state_sensor"
    type: BinarySensor
    capabilities:
      - binary_sensor
    primary_attribute: binary_sensor.state
  - match: "category=zwave_int"
    capabilities:
      - zwave_network
    primary_attribute: zwave_network.state
  - match: "category=doorbell"
    type: BinarySensor
    capabilities:
      - binary_sensor
    primary_attribute: binary_sensor.state
  - match: "category=keypad"
    capabilities:
      - keypad
    primary_attribute: keypad.last_code
  - match: "category=camera"
    capabilities: []  # stub

# The "extensions" section describes capabilities that can span device categories/types.
# These capabilities are added to the established list for the type. The syntax of the
# match critiera and capabilities list is the same as the "mapping" section, but setting
# the "primary_attribute" is not supported here.
extensions:
  - match: "batteryPowered=true;parentDeviceId="  # only apply to parent device
    capabilities:
      - battery_power
  - match: "info.protocol=zwave"
    capabilities:
      - zwave_device
  - match: "info.protocol=zigbee"
    capabilities:
      - zigbee_device
  - match: "[switch]"  # item exists?
    capabilities:
      - power_switch
      - toggle
  - match: "[battery_charging_state]"
    capabilities:
      - x_ezlo_battery_state
      - battery_maintenance
  - match: "[battery_maintenance_state]"
    capabilities:
      - x_ezlo_battery_state
      - battery_maintenance
  - match: "[rgbcolor]"
    capabilities:
      - rgb_color
      - color_temperature
  - match: "[tampering_cover_alarm]"
    capabilities:
      - tamper
  - match: "[battery]"
    capabilities:
      - battery_power
  - match: "[temp]"
    capabilities:
      - temperature_sensor
  - match: "[humidity]"
    capabilities:
      - humidity_sensor
  - match: "[lux]"
    capabilities:
      - light_sensor
  - match: "[electric_meter_kwh]"
    capabilities:
      - "energy_sensor#electric_meter_kwh"
  - match: "[electric_meter_watt]"
    capabilities:
      - "power_sensor#electric_meter_watt"
  - match: "[electric_meter_volt]"
    capabilities:
      - capability: voltage_sensor
        attributes:
          value:
            item: electric_meter_volt
          units:
            item: electric_meter_volt
            value_expr: item?.scale
            map:
              volt: V
              milli-volt: mV
  - match: "[electric_meter_amper]"
    capabilities:
      - capability: current_sensor
        attributes:
          value:
            item: electric_meter_amper
          units:
            item: electric_meter_amper
            value_expr: item?.scale
            map:
              ampere: A
              milli-ampere: mA
