mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2024-11-16 10:28:33 -07:00
Refactor devices.js
This commit is contained in:
parent
500bce2418
commit
59f16f76f1
111
lib/devices.js
111
lib/devices.js
@ -1,110 +1,7 @@
|
||||
const homeassistant = {
|
||||
'binary_sensor_occupancy': {
|
||||
type: 'binary_sensor',
|
||||
object_id: 'occupancy',
|
||||
discovery_payload: {
|
||||
payload_on: 'motion',
|
||||
payload_off: 'no_motion',
|
||||
value_template: '{{ value_json.occupancy }}',
|
||||
device_class: 'motion',
|
||||
json_attributes: ['battery']
|
||||
}
|
||||
},
|
||||
'sensor_illuminance': {
|
||||
type: 'sensor',
|
||||
object_id: 'illuminance',
|
||||
discovery_payload: {
|
||||
unit_of_measurement: 'lx',
|
||||
icon: 'mdi:theme-light-dark',
|
||||
value_template: '{{ value_json.illuminance }}',
|
||||
json_attributes: ['battery'],
|
||||
}
|
||||
},
|
||||
'binary_sensor_state': {
|
||||
type: 'binary_sensor',
|
||||
object_id: 'state',
|
||||
discovery_payload: {
|
||||
payload_on: 'open',
|
||||
payload_off: 'closed',
|
||||
value_template: '{{ value_json.state }}',
|
||||
device_class: 'door',
|
||||
json_attributes: ['battery']
|
||||
}
|
||||
},
|
||||
'binary_sensor_water_leak': {
|
||||
type: 'binary_sensor',
|
||||
object_id: 'water_leak',
|
||||
discovery_payload: {
|
||||
payload_on: true,
|
||||
payload_off: false,
|
||||
value_template: '{{ value_json.water_leak }}',
|
||||
device_class: 'moisture',
|
||||
json_attributes: ['battery']
|
||||
}
|
||||
},
|
||||
'light_brightness_colortemp_xy': {
|
||||
type: 'light',
|
||||
object_id: 'light',
|
||||
discovery_payload: {
|
||||
brightness: true,
|
||||
color_temp: true,
|
||||
xy: true,
|
||||
platform: 'mqtt_json',
|
||||
command_topic: true
|
||||
}
|
||||
},
|
||||
'light_brightness_colortemp': {
|
||||
type: 'light',
|
||||
object_id: 'light',
|
||||
discovery_payload: {
|
||||
brightness: true,
|
||||
color_temp: true,
|
||||
platform: 'mqtt_json',
|
||||
command_topic: true
|
||||
}
|
||||
},
|
||||
'sensor_humidity': {
|
||||
type: 'sensor',
|
||||
object_id: 'humidity',
|
||||
discovery_payload: {
|
||||
unit_of_measurement: '%',
|
||||
icon: 'mdi:water-percent',
|
||||
value_template: '{{ value_json.humidity }}',
|
||||
json_attributes: ['battery'],
|
||||
}
|
||||
},
|
||||
'sensor_temperature': {
|
||||
type: 'sensor',
|
||||
object_id: 'temperature',
|
||||
discovery_payload: {
|
||||
unit_of_measurement: '°C',
|
||||
icon: 'mdi:temperature-celsius',
|
||||
value_template: '{{ value_json.temperature }}',
|
||||
json_attributes: ['battery'],
|
||||
}
|
||||
},
|
||||
'sensor_pressure': {
|
||||
type: 'sensor',
|
||||
object_id: 'pressure',
|
||||
discovery_payload: {
|
||||
unit_of_measurement: 'Pa',
|
||||
icon: 'mdi:speedometer',
|
||||
value_template: '{{ value_json.pressure }}',
|
||||
json_attributes: ['battery'],
|
||||
}
|
||||
},
|
||||
'sensor_button': {
|
||||
type: 'sensor',
|
||||
object_id: 'button',
|
||||
discovery_payload: {
|
||||
icon: 'mdi:toggle-switch',
|
||||
value_template: '{{ value_json.click }}',
|
||||
json_attributes: ['battery'],
|
||||
}
|
||||
}
|
||||
};
|
||||
const homeassistant = require('./homeassistant');
|
||||
|
||||
const devices = {
|
||||
// Xiaomi
|
||||
'lumi.sensor_switch': {
|
||||
model: 'WXKG01LM',
|
||||
vendor: 'Xiaomi',
|
||||
@ -182,6 +79,8 @@ const devices = {
|
||||
supports: 'water leak true/false',
|
||||
homeassistant: [homeassistant.binary_sensor_water_leak]
|
||||
},
|
||||
|
||||
// IKEA
|
||||
'TRADFRI bulb E27 WS opal 980lm': {
|
||||
model: 'LED1545G12',
|
||||
vendor: 'IKEA',
|
||||
@ -196,6 +95,8 @@ const devices = {
|
||||
supports: 'on/off, brightness, color temperature',
|
||||
homeassistant: [homeassistant.light_brightness_colortemp]
|
||||
},
|
||||
|
||||
// Philips
|
||||
'LLC020': {
|
||||
model: '7146060PH',
|
||||
vendor: 'Philips',
|
||||
|
112
lib/homeassistant.js
Normal file
112
lib/homeassistant.js
Normal file
@ -0,0 +1,112 @@
|
||||
const homeassistant = {
|
||||
// Binary sensor
|
||||
'binary_sensor_occupancy': {
|
||||
type: 'binary_sensor',
|
||||
object_id: 'occupancy',
|
||||
discovery_payload: {
|
||||
payload_on: 'motion',
|
||||
payload_off: 'no_motion',
|
||||
value_template: '{{ value_json.occupancy }}',
|
||||
device_class: 'motion',
|
||||
json_attributes: ['battery']
|
||||
}
|
||||
},
|
||||
'binary_sensor_state': {
|
||||
type: 'binary_sensor',
|
||||
object_id: 'state',
|
||||
discovery_payload: {
|
||||
payload_on: 'open',
|
||||
payload_off: 'closed',
|
||||
value_template: '{{ value_json.state }}',
|
||||
device_class: 'door',
|
||||
json_attributes: ['battery']
|
||||
}
|
||||
},
|
||||
'binary_sensor_water_leak': {
|
||||
type: 'binary_sensor',
|
||||
object_id: 'water_leak',
|
||||
discovery_payload: {
|
||||
payload_on: true,
|
||||
payload_off: false,
|
||||
value_template: '{{ value_json.water_leak }}',
|
||||
device_class: 'moisture',
|
||||
json_attributes: ['battery']
|
||||
}
|
||||
},
|
||||
|
||||
// Sensor
|
||||
'sensor_illuminance': {
|
||||
type: 'sensor',
|
||||
object_id: 'illuminance',
|
||||
discovery_payload: {
|
||||
unit_of_measurement: 'lx',
|
||||
icon: 'mdi:theme-light-dark',
|
||||
value_template: '{{ value_json.illuminance }}',
|
||||
json_attributes: ['battery'],
|
||||
}
|
||||
},
|
||||
'sensor_humidity': {
|
||||
type: 'sensor',
|
||||
object_id: 'humidity',
|
||||
discovery_payload: {
|
||||
unit_of_measurement: '%',
|
||||
icon: 'mdi:water-percent',
|
||||
value_template: '{{ value_json.humidity }}',
|
||||
json_attributes: ['battery'],
|
||||
}
|
||||
},
|
||||
'sensor_temperature': {
|
||||
type: 'sensor',
|
||||
object_id: 'temperature',
|
||||
discovery_payload: {
|
||||
unit_of_measurement: '°C',
|
||||
icon: 'mdi:temperature-celsius',
|
||||
value_template: '{{ value_json.temperature }}',
|
||||
json_attributes: ['battery'],
|
||||
}
|
||||
},
|
||||
'sensor_pressure': {
|
||||
type: 'sensor',
|
||||
object_id: 'pressure',
|
||||
discovery_payload: {
|
||||
unit_of_measurement: 'Pa',
|
||||
icon: 'mdi:speedometer',
|
||||
value_template: '{{ value_json.pressure }}',
|
||||
json_attributes: ['battery'],
|
||||
}
|
||||
},
|
||||
'sensor_button': {
|
||||
type: 'sensor',
|
||||
object_id: 'button',
|
||||
discovery_payload: {
|
||||
icon: 'mdi:toggle-switch',
|
||||
value_template: '{{ value_json.click }}',
|
||||
json_attributes: ['battery'],
|
||||
}
|
||||
},
|
||||
|
||||
// Light
|
||||
'light_brightness_colortemp_xy': {
|
||||
type: 'light',
|
||||
object_id: 'light',
|
||||
discovery_payload: {
|
||||
brightness: true,
|
||||
color_temp: true,
|
||||
xy: true,
|
||||
platform: 'mqtt_json',
|
||||
command_topic: true
|
||||
}
|
||||
},
|
||||
'light_brightness_colortemp': {
|
||||
type: 'light',
|
||||
object_id: 'light',
|
||||
discovery_payload: {
|
||||
brightness: true,
|
||||
color_temp: true,
|
||||
platform: 'mqtt_json',
|
||||
command_topic: true
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = homeassistant;
|
Loading…
Reference in New Issue
Block a user