UNPKG

iobroker.zigbee2mqtt

Version:
1,900 lines (1,877 loc) 187 kB
/* eslint-disable no-prototype-builtins */ 'use strict'; /*eslint no-unused-vars: ['off']*/ const rgb = require('./rgb.js'); const utils = require('./utils.js'); const colors = require('./colors.js'); /* states for device: id - sysname of state, id name - display name of state prop - attr name of payload object with value of state icon - url of state icon role - state role write, read - allow to write and read state from admin type - type of value isEvent - sign of clearing the value after 300ms isOption - if state is internal setting, not to be sent to device inOptions - if true, value of this state will be included in options argument of other states setter(Opt) getter - result of call is the value of state. if value is undefined - state not apply setter - result of call is the value for publish to zigbee setterOpt - result of call is the options for publish to zigbee setattr - name of converter to zigbee, if it different from "prop" value epname - endpoint name for publish lazy - if true, then the state will not be created until the first event for the specified state arrives */ const nameLookup = { C: 'temperature', '%': 'humidity', m: 'altitude', Pa: 'pressure', ppm: 'quality', psize: 'particle_size', V: 'voltage', A: 'current', Wh: 'energy', W: 'power', Hz: 'frequency', pf: 'power_factor', lx: 'illuminance_lux', }; const unitLookup = { temperature: 'C', humidity: '%', altitude: 'm', pressure: 'Pa', quality: 'ppm', particle_size: 'psize', voltage: 'V', current: 'A', energy: 'Wh', power: 'W', frequency: 'Hz', power_factor: 'pf', illuminance_lux: 'lx', }; const timers = {}; const states = { link_quality: { id: 'link_quality', prop: 'linkquality', name: 'Link quality', icon: undefined, role: 'state', write: false, read: true, type: 'number', def: 0, min: 0, max: 255, }, available: { id: 'available', prop: 'available', name: 'Available', icon: undefined, role: 'indicator.reachable', write: false, read: true, type: 'boolean', def: false, }, last_seen: { id: 'last_seen', prop: 'last_seen', name: 'The date/time of last Zigbee message', icon: undefined, role: 'state', write: false, read: true, type: 'string', def: '', getter: (payload) => { return payload.last_seen.replace('T', ' ').split('+')[0]; }, }, color_read: { id: 'color', prop: 'action', name: 'Color', icon: undefined, role: 'level.color.rgb', write: false, read: true, type: 'string', def: '#ffffff', getter: (payload) => { if (payload.action != 'color_wheel') { return undefined; } if (payload.color && payload.color.hasOwnProperty('x') && payload.color.hasOwnProperty('y')) { const colorval = rgb.cie_to_rgb(payload.color.x, payload.color.y); return ( '#' + utils.decimalToHex(colorval[0]) + utils.decimalToHex(colorval[1]) + utils.decimalToHex(colorval[2]) ); } else { return undefined; } }, }, simulated_brightness: { id: 'simulated_brightness', prop: 'brightness', name: 'Simulated brightness', icon: undefined, role: 'level.dimmer', write: true, read: true, type: 'number', def: 0, unit: '%', getter: (payload) => { return utils.bulbLevelToAdapterLevel(payload.brightness); }, }, state: { id: 'state', name: 'Switch state', icon: undefined, role: 'switch', write: true, read: true, type: 'boolean', def: false, getter: (payload) => payload.state === 'ON', setter: (value) => (value ? 'ON' : 'OFF'), }, brightness: { id: 'brightness', name: 'Brightness', options: ['transition'], icon: undefined, role: 'level.dimmer', write: true, read: true, type: 'number', unit: '%', min: 0, max: 100, def: 100, getter: (payload) => { return utils.bulbLevelToAdapterLevel(payload.brightness); }, setter: (value) => { return utils.adapterLevelToBulbLevel(value); }, }, brightness_move: { id: 'brightness_move', prop: 'brightness_move', name: 'Dimming', icon: undefined, role: 'state', write: true, read: false, type: 'number', min: -50, max: 50, def: 0, }, colortemp_move: { id: 'colortemp_move', prop: 'color_temp_move', name: 'Colortemp change', icon: undefined, role: 'state', write: true, read: false, type: 'number', min: -50, max: 50, def: 0, }, transition: { id: 'transition', prop: 'transition', name: 'Transition time overwrite (-1 disabled)', icon: undefined, role: 'state', write: true, read: false, type: 'number', unit: 'sec', min: -1, max: 65535, def: -1, isOption: true, }, send_payload: { id: 'send_payload', name: 'Send a raw json payload', icon: undefined, role: 'json', write: true, read: false, type: 'string', def: '{}', }, //################################################################# device_query: { // button to trigger device read id: 'device_query', prop: 'device_query', name: 'Trigger device query', icon: undefined, role: 'button', write: true, read: false, type: 'boolean', isOption: true, }, from_zigbee: { id: 'msg_from_zigbee', name: 'Message from Zigbee', icon: undefined, role: 'state', write: false, read: true, type: 'string', }, checking: { // press button for checking id: 'checking', name: 'Start checking process', icon: undefined, role: 'button', write: true, read: false, type: 'boolean', }, click: { id: 'click', name: 'Click event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'single' ? true : undefined), }, double_click: { id: 'double_click', prop: 'click', name: 'Double click event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'double' ? true : undefined), }, action: { id: 'action', prop: 'action', name: 'button action', role: 'button', write: false, read: true, type: 'text', }, action_single: { id: 'click', prop: 'action', name: 'Click event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'single' ? true : undefined), }, action_click: { id: 'click', prop: 'action', name: 'Click event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'click' ? true : undefined), }, action_double_click: { id: 'double_click', prop: 'action', name: 'Double click event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'double' ? true : undefined), }, action_group: { id: 'action_group', prop: 'action_group', name: 'Action group', role: 'state', write: false, read: true, type: 'number', def: 0, }, triple_click: { id: 'triple_click', prop: 'click', name: 'Triple click event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'triple' ? true : undefined), }, quad_click: { id: 'quad_click', prop: 'click', name: 'Quadruple click event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'quadruple' ? true : undefined), }, many_click: { id: 'many_click', prop: 'click', name: 'Many clicks event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'many' ? true : undefined), }, long_click: { id: 'long_click', prop: 'click', name: 'Long click event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'long' ? true : undefined), }, action_long_click: { id: 'long_click', prop: 'action', name: 'Long click event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'long' ? true : undefined), }, long_press: { id: 'long_press', prop: 'click', name: 'Long press', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', getter: (payload) => (payload.click === 'long' ? true : payload.click === 'long_release' ? false : undefined), }, voltage: { id: 'voltage', name: 'Voltage', icon: undefined, role: 'value.voltage', write: false, read: true, type: 'number', unit: 'V', def: 0, }, battery_voltage: { id: 'voltage', name: 'Battery voltage', icon: undefined, role: 'battery.voltage', write: false, read: true, type: 'number', unit: 'V', def: 0, }, energy: { id: 'energy', name: 'Sum of consumed energy', icon: undefined, role: 'value.power.consumption', write: false, read: true, type: 'number', unit: 'kWh', def: 0, }, battery: { id: 'battery', prop: 'battery', name: 'Battery percent', icon: undefined, role: 'value.battery', write: false, read: true, type: 'number', unit: '%', min: 0, max: 100, def: 0, }, left_click: { id: 'left_click', prop: 'click', name: 'Left click event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'left' ? true : undefined), }, right_click: { id: 'right_click', prop: 'click', name: 'Right click event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'right' ? true : undefined), }, both_click: { id: 'both_click', prop: 'click', name: 'Both click event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'both' ? true : undefined), }, left_click_single: { id: 'left_click', prop: 'click', name: 'Left click event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'left_single' ? true : undefined), }, right_click_single: { id: 'right_click', prop: 'click', name: 'Right click event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'right_single' ? true : undefined), }, both_click_single: { id: 'both_click', prop: 'click', name: 'Both click event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'both_single' ? true : undefined), }, left_click_long: { id: 'left_click_long', prop: 'click', name: 'Left click long event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'left_long' ? true : undefined), }, left_click_double: { id: 'left_click_double', prop: 'click', name: 'Left click double event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'left_double' ? true : undefined), }, right_click_long: { id: 'right_click_long', prop: 'click', name: 'Right click long event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'right_long' ? true : undefined), }, right_click_double: { id: 'right_click_double', prop: 'click', name: 'Right click double event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'right_double' ? true : undefined), }, both_click_long: { id: 'both_click_long', prop: 'click', name: 'Both click long event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'both_long' ? true : undefined), }, both_click_double: { id: 'both_click_double', prop: 'click', name: 'Both click double event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.click === 'both_double' ? true : undefined), }, stateEp: { id: 'state', name: 'Switch state', icon: undefined, role: 'switch', write: true, read: true, type: 'boolean', getter: (payload) => payload.state === 'ON', setter: (value) => (value ? 'ON' : 'OFF'), epname: 'default', }, left_state: { id: 'left_state', prop: 'state_left', name: 'Left switch state', icon: undefined, role: 'switch', write: true, read: true, type: 'boolean', getter: (payload) => payload.state_left === 'ON', setter: (value) => (value ? 'ON' : 'OFF'), setattr: 'state', epname: 'left', }, right_state: { id: 'right_state', prop: 'state_right', name: 'Right switch state', icon: undefined, role: 'switch', write: true, read: true, type: 'boolean', getter: (payload) => payload.state_right === 'ON', setter: (value) => (value ? 'ON' : 'OFF'), setattr: 'state', epname: 'right', }, center_state: { id: 'center_state', prop: 'state_center', name: 'Center switch state', icon: undefined, role: 'switch', write: true, read: true, type: 'boolean', getter: (payload) => payload.state_center === 'ON', setter: (value) => (value ? 'ON' : 'OFF'), setattr: 'state', epname: 'center', }, left_button: { id: 'left_button', prop: 'button_left', name: 'Left button pressed', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', getter: (payload) => payload.button_left === 'hold', }, right_button: { id: 'right_button', prop: 'button_right', name: 'Right button pressed', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', getter: (payload) => payload.button_right === 'hold', }, device_temperature: { id: 'device_temperature', name: 'Temperature of the device', icon: undefined, role: 'value.temperature', write: false, read: true, type: 'number', unit: '°C', def: 0, }, temperature: { id: 'temperature', name: 'Temperature', icon: undefined, role: 'value.temperature', write: false, read: true, type: 'number', unit: '°C', def: 0, }, humidity: { id: 'humidity', name: 'Humidity', icon: undefined, role: 'value.humidity', write: false, read: true, type: 'number', def: 0, unit: '%', min: 0, max: 100, }, pressure: { id: 'pressure', name: 'Pressure', icon: undefined, role: 'value.pressure', write: false, read: true, type: 'number', def: 0, unit: 'hPa', min: 0, max: 10000, }, illuminance: { id: 'illuminance', prop: 'illuminance_lux', name: 'Illuminance', icon: undefined, role: 'value.brightness', write: false, read: true, type: 'number', def: 0, unit: 'lux', }, illuminance_raw: { id: 'illuminance_raw', prop: 'illuminance', name: 'Illuminance raw', icon: undefined, role: 'value.brightness', write: false, read: true, type: 'number', def: 0, unit: '', }, occupancy: { id: 'occupancy', name: 'Occupancy', icon: undefined, role: 'sensor.motion', write: false, read: true, type: 'boolean', def: false, }, occupancy_event: { id: 'occupancy', name: 'Occupancy event', icon: undefined, role: 'sensor.motion', write: false, read: true, type: 'boolean', isEvent: true, def: false, }, occupancy_pirOToUDelay: { // this is different from occupancy_timeout, // is writable timeout (to device). id: 'occupancy_timeout', prop: 'occupancy_timeout', name: 'Delay Occupied to Unoccupied', icon: undefined, role: 'variable', write: true, read: true, type: 'number', def: 0, epname: 'ep2', // philips hue sml001 }, no_motion: { id: 'no_motion', prop: 'occupancy', name: 'Time from last motion', icon: undefined, role: 'state', write: false, read: true, type: 'number', def: 0, unit: 'seconds', prepublish: (devId, value, callback, options) => { if (value) { if (timers[devId]) { clearInterval(timers[devId]); delete timers[devId]; } callback(0); } else { if (!timers[devId]) { const hasTimeout = options && options.hasOwnProperty('occupancy_timeout'); let counter = hasTimeout ? options.occupancy_timeout : 60; callback(counter); timers[devId] = setInterval(() => { counter = counter + 10; callback(counter); if (counter > 1800) { // cancel after 1800 sec clearInterval(timers[devId]); delete timers[devId]; } }, 10000); // update every 10 second } } }, }, contact: { id: 'contact', prop: 'contact', name: 'Contact event', icon: undefined, role: 'state', write: false, read: true, type: 'boolean', def: false, }, opened: { id: 'opened', prop: 'contact', name: 'Is open', icon: undefined, role: 'sensor.window', write: false, read: true, type: 'boolean', def: false, getter: (payload) => !payload.contact, }, tamper: { id: 'tampered', prop: 'tamper', name: 'Is tampered', icon: undefined, role: 'state', write: false, read: true, type: 'boolean', }, water_detected: { id: 'detected', prop: 'water_leak', name: 'Water leak detected', icon: undefined, role: 'indicator.alarm.flood', write: false, read: true, type: 'boolean', def: false, }, gas_detected: { id: 'detected', prop: 'gas', name: 'Gas leak detected', icon: undefined, role: 'indicator.alarm.fire', write: false, read: true, type: 'boolean', def: false, }, smoke_detected: { id: 'detected', prop: 'smoke', name: 'Smoke leak detected', icon: undefined, role: 'indicator.alarm.fire', write: false, read: true, type: 'boolean', def: false, }, smoke_detected2: { // for Heiman id: 'smoke', prop: 'smoke', name: 'Smoke leak detected', icon: undefined, role: 'indicator.alarm.fire', write: false, read: true, type: 'boolean', def: false, }, co_detected: { // for Heiman id: 'carbon_monoxide', prop: 'carbon_monoxide', name: 'CO leak detected', icon: undefined, role: 'indicator.alarm.carbon_monoxide', write: false, read: true, type: 'boolean', def: false, }, heiman_batt_low: { id: 'battery_low', prop: 'battery_low', name: 'Battery Status Low', icon: undefined, role: 'indicator.lowbat', write: false, read: true, type: 'boolean', def: false, }, heiman_battery: { id: 'battery', prop: 'battery', name: 'Battery percent', icon: undefined, role: 'battery.percent', write: false, read: true, type: 'number', unit: '%', min: 0, max: 100, def: 0, }, heiman_smart_controller_armed: { id: 'arm_state', prop: 'action', name: 'Alarm Armed State', icon: undefined, role: 'button', write: false, read: true, type: 'string', getter: (payload) => (payload.action === 'armmode_disarm' ? false : true), }, heiman_smart_controller_arm_mode: { id: 'arm_mode', prop: 'action', name: 'Alarm Armed State', icon: undefined, role: 'button', write: false, read: true, type: 'string', getter: (payload) => (payload.action === 'armmode_arm_all_zones' ? 'full' : 'partial'), }, heiman_smart_controller_emergency: { id: 'emergency', prop: 'action', name: 'Emergency', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', getter: (payload) => (payload.action === 'emergency' ? true : false), }, heiman_execute_warning: { // for HEIMAN HS2WD-E id: 'execute_warning', prop: 'warning', name: 'Execute warning (input: duration in sec)', icon: undefined, role: 'state', write: true, read: true, type: 'number', def: 0, setter: (value) => { return { strobe: true, duration: value }; }, }, heiman_execute_warning_strobe_only: { // for HEIMAN HS2WD-E id: 'execute_warning_strobe_only', prop: 'warning', name: 'Execute warning strobe only (input: duration in sec)', icon: undefined, role: 'state', write: true, read: true, type: 'number', def: 0, setter: (value) => { return { mode: 'stop', strobe: true, duration: value }; }, }, bitron_execute_warning: { // for Biton AV2010/24A id: 'execute_warning', prop: 'warning', name: 'Execute warning (input: duration in sec)', icon: undefined, role: 'state', write: true, read: true, type: 'number', def: 0, setter: (value) => { return { strobe: false, duration: value }; }, }, shake: { id: 'shake', prop: 'action', name: 'Shake event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'shake' ? true : undefined), }, wakeup: { id: 'wakeup', prop: 'action', name: 'Wakeup event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'wakeup' ? true : undefined), }, fall: { id: 'fall', prop: 'action', name: 'Free fall event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'fall' ? true : undefined), }, tap: { id: 'tap', prop: 'action', name: 'Tapped twice event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'tap' ? true : undefined), }, tap_side: { id: 'tap_side', prop: 'side', name: 'Top side on tap', icon: undefined, role: 'state', write: false, read: true, type: 'number', def: 0, getter: (payload) => (payload.action === 'tap' ? payload.side : undefined), }, slide: { id: 'slide', prop: 'action', name: 'Slide event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'slide' ? true : undefined), }, slide_side: { id: 'slide_side', prop: 'side', name: 'Top side on slide', icon: undefined, role: 'state', write: false, read: true, type: 'number', def: 0, getter: (payload) => (payload.action === 'slide' ? payload.side : undefined), }, flip180: { id: 'flip180', prop: 'action', name: 'Flip on 180°', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'flip180' ? true : undefined), }, flip180_side: { id: 'flip180_side', prop: 'side', name: 'Top side on flip 180°', icon: undefined, role: 'state', write: false, read: true, type: 'number', def: 0, getter: (payload) => (payload.action === 'flip180' ? payload.side : undefined), }, flip90: { id: 'flip90', prop: 'action', name: 'Flip on 90° event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'flip90' ? true : undefined), }, flip90_from: { id: 'flip90_from', prop: 'from_side', name: 'From top side on flip 90°', icon: undefined, role: 'state', write: false, read: true, type: 'number', def: 0, getter: (payload) => (payload.action === 'flip90' ? payload.from_side : undefined), }, flip90_to: { id: 'flip90_to', prop: 'to_side', name: 'To top side on flip 90°', icon: undefined, role: 'state', write: false, read: true, type: 'number', def: 0, getter: (payload) => (payload.action === 'flip90' ? payload.to_side : undefined), }, rotate_left: { id: 'rotate_left', prop: 'action', name: 'Rotate left event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'rotate_left' ? true : undefined), }, rotate_right: { id: 'rotate_right', prop: 'action', name: 'Rotate right event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'rotate_right' ? true : undefined), }, rotate_stop: { id: 'rotate_stop', prop: 'action', name: 'Rotate stop event', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'rotate_stop' ? true : undefined), }, rotate_angle: { id: 'rotate_angle', prop: 'angle', name: 'Rotate angle', icon: undefined, role: 'state', write: false, read: true, type: 'number', def: 0, }, action_play_pause: { id: 'button_play_pause', prop: 'action', name: 'Play/Pause Button', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'play_pause' ? true : undefined), }, load_power: { id: 'load_power', prop: 'power', name: 'Load power', icon: undefined, role: 'value.power', write: false, read: true, type: 'number', def: 0, unit: 'W', }, plug_voltage: { id: 'voltage', name: 'Load voltage', icon: undefined, role: 'value', write: false, read: true, type: 'number', def: 0, unit: 'V', }, load_current: { id: 'load_current', prop: 'current', name: 'Load current', icon: undefined, role: 'value.current', write: false, read: true, type: 'number', unit: 'A', def: 0, }, plug_consumption: { id: 'consumption', name: 'Consumption', icon: undefined, role: 'value', write: false, read: true, type: 'number', def: 0, }, plug_temperature: { id: 'temperature', name: 'Temperature', icon: undefined, role: 'value', write: false, read: true, type: 'number', def: 0, }, plug_consumer_connected: { id: 'consumer_connected', name: 'Consumer connection status', icon: undefined, role: 'state', write: false, read: true, type: 'boolean', }, plug_consumer_overloaded: { id: 'consumer_overloaded', name: 'Overload by the consumer', icon: undefined, role: 'value.power', write: false, read: true, type: 'number', unit: 'W', def: 0, }, plug_power_outage_memory: { id: 'power_outage_memory', name: 'On/off state restore after power loss', icon: undefined, role: 'switch', write: true, read: true, type: 'boolean', }, plug_auto_off: { id: 'auto_off', name: 'Auto switch off with load lower than 2.6 W during 20 minutes', icon: undefined, role: 'switch', write: true, read: true, type: 'boolean', }, plug_led_disabled_night: { id: 'led_disabled_night', name: 'Disable LED at night', icon: undefined, role: 'switch', write: true, read: true, type: 'boolean', }, brightness_readonly: { id: 'brightness', name: 'Brightness', icon: undefined, role: 'level.dimmer', write: false, read: true, type: 'number', unit: '', min: 0, max: 100, def: 0, getter: (payload) => { return utils.bulbLevelToAdapterLevel(payload.brightness); }, }, colortemp: { id: 'colortemp', prop: 'color_temp', name: 'Color temperature', icon: undefined, role: 'level.color.temperature', write: true, read: true, type: 'number', def: 0, setter: (value) => { return utils.toMired(value); }, setterOpt: (value, options) => { const hasTransitionTime = options && options.hasOwnProperty('transition_time'); const transitionTime = hasTransitionTime ? options.transition_time : 0; return { ...options, transition: transitionTime }; }, }, color: { id: 'color', prop: 'color', name: 'Color', icon: undefined, role: 'level.color.rgb', write: true, read: true, type: 'string', setter: (value) => { let xy = [0, 0]; const rgbcolor = colors.ParseColor(value); xy = rgb.rgb_to_cie(rgbcolor.r, rgbcolor.g, rgbcolor.b); return { x: xy[0], y: xy[1], }; }, // setterOpt: (value, options) => { // const hasTransitionTime = options && options.hasOwnProperty('transition_time'); // const transitionTime = hasTransitionTime ? options.transition_time : 0; // return { ...options, transition: transitionTime }; // }, getter: (payload) => { if (payload.color_mode != 'xy') { return undefined; } if (payload.color && payload.color.hasOwnProperty('x') && payload.color.hasOwnProperty('y')) { const colorval = rgb.cie_to_rgb(payload.color.x, payload.color.y); return ( '#' + utils.decimalToHex(colorval[0]) + utils.decimalToHex(colorval[1]) + utils.decimalToHex(colorval[2]) ); } else { return undefined; } }, }, operation_mode: { id: 'decoupled', prop: 'operation_mode', name: 'Decoupled mode', icon: undefined, role: 'state', write: true, read: true, type: 'boolean', setter: (value) => { return { button: 'single', state: value ? 'decoupled' : 'control_relay' }; }, }, operation_mode_left: { id: 'decoupled_left', prop: 'operation_mode', name: 'Left decoupled mode', icon: undefined, role: 'state', write: true, read: true, type: 'boolean', setter: (value) => { return { button: 'left', state: value ? 'decoupled' : 'control_left_relay' }; }, }, operation_mode_right: { id: 'decoupled_right', prop: 'operation_mode', name: 'Right decoupled mode', icon: undefined, role: 'state', write: true, read: true, type: 'boolean', setter: (value) => { return { button: 'right', state: value ? 'decoupled' : 'control_right_relay' }; }, }, temp_calibration: { id: 'temperature_calibration', prop: 'temperature_calibration', name: 'Temperature Calibration Offset', icon: undefined, role: 'value.temperature', write: true, read: true, type: 'number', def: 0, unit: '°C', isOption: true, }, illuminance_calibration: { id: 'illuminance_calibration', prop: 'illuminance_calibration', name: 'Illuminance Calibration Percentage', icon: undefined, role: 'value.brightness', write: true, read: true, type: 'number', def: 0, unit: '%', isOption: true, }, humidity_calibration: { id: 'humidity_calibration', prop: 'humidity_calibration', name: 'Humidity Calibration Percentage', icon: undefined, role: 'value.humidity', write: true, read: true, type: 'number', def: 0, unit: '%', isOption: true, }, // osram switch mini switch_circle: { id: 'circle', prop: 'action', name: 'Circle state', icon: undefined, role: 'switch', write: false, read: true, type: 'string', getter: (payload) => payload.action === 'circle_click' ? 'press' : payload.action === 'circle_hold' ? 'hold' : undefined, }, switch_state: { id: 'state', prop: 'action', name: 'Switch state', icon: undefined, role: 'switch', write: false, read: true, type: 'string', getter: (payload) => payload.action === 'up' ? 'up' : payload.action === 'down' ? 'down' : payload.action === 'circle_click' ? 'circle' : undefined, }, switch_hold: { id: 'hold', prop: 'action', name: 'Switch state', icon: undefined, role: 'switch', write: false, read: true, type: 'string', getter: (payload) => payload.action === 'up_hold' ? 'up' : payload.action === 'down_hold' ? 'down' : payload.action === 'circle_hold' ? 'circle' : undefined, }, switch_release: { id: 'release', prop: 'action', name: 'Switch state', icon: undefined, role: 'switch', write: false, read: true, type: 'string', getter: (payload) => payload.action === 'up_release' ? 'up' : payload.action === 'down_release' ? 'down' : payload.action === 'circle_release' ? 'circle' : undefined, }, // new RWL states rwl_state: { id: 'state', prop: 'action', name: 'Switch state', icon: undefined, role: 'switch', write: false, read: true, type: 'boolean', getter: (payload) => payload.action === 'on-press' ? true : payload.action === 'off-press' ? false : undefined, }, rwl_up_button: { id: 'up_button', prop: 'action', name: 'Up button pressed', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'up-press' ? true : undefined), }, rwl_up_hold: { id: 'up_hold', prop: 'action', name: 'Up button hold', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'up-hold' ? true : undefined), }, rwl_down_button: { id: 'down_button', prop: 'action', name: 'Down button pressed', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'down-press' ? true : undefined), }, rwl_down_hold: { id: 'down_hold', prop: 'action', name: 'Down button hold', icon: undefined, role: 'button', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'down-hold' ? true : undefined), }, rwl_counter: { id: 'click_count', prop: 'counter', name: 'Click count per action', icon: undefined, role: 'state', write: false, read: true, type: 'number', def: 0, }, rwl_duration: { id: 'press_duration', prop: 'duration', name: 'Press duration', icon: undefined, role: 'state', write: false, read: true, type: 'number', def: 0, }, rwl_multiple_press_timeout: { id: 'multiple_press_timeout', prop: 'multiple_press_timeout', name: 'Multiple press timeout', icon: undefined, role: 'state', write: true, read: true, type: 'number', def: 0, unit: 'sec', isOption: true, }, /* sml_sensitivity: { id: 'motion_sensitivity', prop: 'motion_sensitivity', name: 'Motion Sensitivity (0-2)', icon: undefined, role: 'state', write: true, read: true, type: 'number', def: 0, min: 0, max: 2, epname: 'ep2', getter: (payload) => (['low','medium','high'].indexOf(payload)), setter: (value) => (['low','medium','high'][value]), }, */ sml_sensitivity: { id: 'motion_sensitivity', prop: 'motion_sensitivity', name: 'Motion Sensitivity', icon: undefined, role: 'state', write: true, read: true, type: 'string', states: { low: 'low', medium: 'medium', high: 'high' }, epname: 'ep2', }, occupancy_timeout: { id: 'occupancy_timeout', name: 'Occupancy timeout', icon: undefined, role: 'state', write: true, read: false, type: 'number', def: 0, unit: 'sec', isOption: true, }, rotate_direction: { id: 'direction', name: 'rotate direction', icon: undefined, prop: 'direction', role: 'state', write: false, read: true, type: 'string', }, rotate_number: { id: 'number', name: 'rotate number', icon: undefined, prop: 'number', role: 'state', write: false, read: true, type: 'number', def: 0, }, DNCKAT_state_1: { id: 'state_1', prop: 'state_left', name: 'Switch state 1', icon: undefined, role: 'switch', write: true, read: true, type: 'boolean', getter: (payload) => payload.state_left === 'ON', setter: (value) => (value ? 'ON' : 'OFF'), setattr: 'state', epname: 'left', }, DNCKAT_state_2: { id: 'state_2', prop: 'state_right', name: 'Switch state 2', icon: undefined, role: 'switch', write: true, read: true, type: 'boolean', getter: (payload) => payload.state_right === 'ON', setter: (value) => (value ? 'ON' : 'OFF'), setattr: 'state', epname: 'right', }, DNCKAT_state_3: { id: 'state_3', prop: 'state_center', name: 'Switch state 3', icon: undefined, role: 'switch', write: true, read: true, type: 'boolean', getter: (payload) => payload.state_center === 'ON', setter: (value) => (value ? 'ON' : 'OFF'), setattr: 'state', epname: 'center', }, DNCKAT_state_41: { id: 'state_1', prop: 'state_bottom_left', name: 'Switch state 1', icon: undefined, role: 'switch', write: true, read: true, type: 'boolean', getter: (payload) => payload.state_bottom_left === 'ON', setter: (value) => (value ? 'ON' : 'OFF'), setattr: 'state', epname: 'bottom_left', }, DNCKAT_state_42: { id: 'state_2', prop: 'state_bottom_right', name: 'Switch state 2', icon: undefined, role: 'switch', write: true, read: true, type: 'boolean', getter: (payload) => payload.state_bottom_right === 'ON', setter: (value) => (value ? 'ON' : 'OFF'), setattr: 'state', epname: 'bottom_right', }, DNCKAT_state_43: { id: 'state_3', prop: 'state_top_left', name: 'Switch state 3', icon: undefined, role: 'switch', write: true, read: true, type: 'boolean', getter: (payload) => payload.state_top_left === 'ON', setter: (value) => (value ? 'ON' : 'OFF'), setattr: 'state', epname: 'top_left', }, DNCKAT_state_44: { id: 'state_4', prop: 'state_top_right', name: 'Switch state 4', icon: undefined, role: 'switch', write: true, read: true, type: 'boolean', getter: (payload) => payload.state_top_right === 'ON', setter: (value) => (value ? 'ON' : 'OFF'), setattr: 'state', epname: 'top_right', }, vibration_action: { id: 'vibration', prop: 'action', name: 'Vibration event', icon: undefined, role: 'state', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'vibration' ? true : undefined), }, tilt_action: { id: 'tilt', prop: 'action', name: 'Tilt event', icon: undefined, role: 'state', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'tilt' ? true : undefined), }, drop_action: { id: 'drop', prop: 'action', name: 'Drop event', icon: undefined, role: 'state', write: false, read: true, type: 'boolean', isEvent: true, getter: (payload) => (payload.action === 'drop' ? true : undefined), }, tilt_angle: { id: 'tilt_angle', prop: 'angle', name: 'Tilt angle', icon: undefined, role: 'state', write: false, read: true, type: 'number', def: 0, }, tilt_angle_x: { id: 'tilt_angle_x', prop: 'angle_x', name: 'Tilt angle X', icon: undefined, role: 'state', write: false, read: true, type: 'number', def: 0, }, tilt_angle_y: { id: 'tilt_angle_y', prop: 'angle_y', name: 'Tilt angle Y', icon: undefined, role: 'state', write: false, read: true, type: 'number', def: 0, }, tilt_angle_z: { id: 'tilt_angle_z', prop: 'angle_z', name: 'Tilt angle Z', icon: undefined, role: 'state', write: false, read: true, type: 'number', def: 0, }, tilt_angle_x_abs: { id: 'tilt_angle_x_abs', prop: 'angle_x_absolute', name: 'Tilt angle X absolute ', icon: undefined, role: 'state', write: false, read: true, type: 'number', def: 0, }, tilt_angle_y_ab