Skip to content

Commit

Permalink
Update zigbee-herdsman-converters to 12.0.225 (Koenkk#4850)
Browse files Browse the repository at this point in the history
* Update zigbee-herdsman-converters to 12.0.225

* Update homeassistant.js

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Koen Kanters <[email protected]>
  • Loading branch information
github-actions[bot] and Koenkk authored Nov 2, 2020
1 parent 195d56d commit 2ee3b5f
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 70 deletions.
127 changes: 61 additions & 66 deletions lib/extension/homeassistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,6 @@ const cfg = {
value_template: '{{ value_json.click }}',
},
},
'sensor_power': {
type: 'sensor',
object_id: 'power',
discovery_payload: {
unit_of_measurement: 'W',
icon: 'mdi:flash',
value_template: '{{ value_json.power }}',
},
},
'sensor_energy': {
type: 'sensor',
object_id: 'energy',
discovery_payload: {
unit_of_measurement: 'kWh',
icon: 'mdi:power-plug',
value_template: '{{ value_json.energy }}',
},
},
'sensor_brightness': {
type: 'sensor',
object_id: 'brightness',
Expand Down Expand Up @@ -187,6 +169,7 @@ const cfg = {
},
};

/* istanbul ignore next */
const climate = (minTemp=7, maxTemp=30, temperatureStateProperty='occupied_heating_setpoint',
tempStep=1, systemModes=['off', 'auto', 'heat'], fanModes=[], holdModes=[],
temperatureLowStateTopic=false, temperatureHighStateTopic=false, endpoint=null ) => {
Expand Down Expand Up @@ -278,47 +261,6 @@ const climate = (minTemp=7, maxTemp=30, temperatureStateProperty='occupied_heati

// Map Home Assistant configurations to devices.
const manualMaping = {
'1TST-EU': [climate(), cfg.sensor_battery],
'AV2010/32': [climate(7, 30, 'occupied_heating_setpoint', 0.5), cfg.sensor_battery],
'SPZB0001': [climate(5, 30, 'occupied_heating_setpoint', 0.5), cfg.sensor_battery],
'ST218': [
climate(5, 30, 'occupied_heating_setpoint', 0.5),
cfg.sensor_local_temperature,
cfg.lock_keypad_lockout,
],
'TH1123ZB': [
climate(7, 30, 'occupied_heating_setpoint', 0.5), cfg.sensor_local_temperature,
cfg.lock_keypad_lockout, cfg.sensor_power, cfg.sensor_energy,
],
'TH1124ZB': [
climate(7, 30, 'occupied_heating_setpoint', 0.5), cfg.sensor_local_temperature,
cfg.lock_keypad_lockout, cfg.sensor_power, cfg.sensor_energy,
],
'TH1300ZB': [
climate(7, 30, 'occupied_heating_setpoint', 0.5), cfg.sensor_local_temperature,
cfg.lock_keypad_lockout,
],
'TH1400ZB': [climate()],
'TH1500ZB': [climate()],
'Zen-01-W': [climate(10, 30, 'occupied_heating_setpoint', 0.5)],
'UK7004240': [climate(), cfg.sensor_battery],
'WV704R0A0902': [climate()],
'STZB402': [
climate(5, 30, 'occupied_heating_setpoint', 0.5),
cfg.sensor_local_temperature,
cfg.lock_keypad_lockout,
],
'SMT402': [
climate(5, 30, 'occupied_heating_setpoint', 0.5),
cfg.sensor_local_temperature,
cfg.lock_keypad_lockout,
],
'SMT402AD': [
climate(5, 30, 'occupied_heating_setpoint', 0.5),
cfg.sensor_local_temperature,
cfg.lock_keypad_lockout,
],
'SLR1b': [climate()],
'GS361A-H04': [
cfg.lock_child_lock,
cfg.switch_window_detection,
Expand Down Expand Up @@ -350,9 +292,6 @@ const manualMaping = {
climate(5, 35, 'current_heating_setpoint', 0.5,
['off', 'heat', 'auto'], [], ['none', 'away']),
],
'ZK03840': [climate()],
'U86KWF-ZPSJ': [climate(5, 30, 'current_heating_setpoint', 0.5)],
'D3-DPWK-TY': [climate(5, 30, 'current_heating_setpoint', 0.5)],
'BHT-002-GCLZB': [
cfg.lock_child_lock, climate(5, 30, 'current_heating_setpoint', 1, ['off', 'heat'], [], ['hold', 'program']),
],
Expand All @@ -368,7 +307,6 @@ const manualMaping = {
cfg.binary_sensor_battery_low,
climate(5, 30, 'current_heating_setpoint', 0.5, ['off', 'heat'], [], ['manual', 'auto']),
],
'HY08WE': [climate(5, 30, 'current_heating_setpoint', 0.5)],
};

const defaultStatusTopic = 'homeassistant/status';
Expand Down Expand Up @@ -463,18 +401,74 @@ class HomeAssistant extends Extension {
command_topic_prefix: expose.endpoint ? expose.endpoint : undefined,
},
};
} else if (expose.type === 'climate') {
assert(!expose.endpoint, `Endpoint not supported for climate type`);
const setpointProperties = ['occupied_heating_setpoint', 'current_heating_setpoint'];
const setpoint = expose.features.find((f) => setpointProperties.includes(f.name));
assert(setpoint, 'No setpoint found');
const temperature = expose.features.find((f) => f.name === 'local_temperature');
assert(temperature, 'No temperature found');
const mode = expose.features.find((f) => f.name === 'system_mode');
assert(mode, 'No mode found');
const state = expose.features.find((f) => f.name === 'running_state');
assert(state, 'No state found');

discoveryEntry = {
type: 'climate',
object_id: expose.endpoint ? `climate_${expose.endpoint}` : 'climate',
discovery_payload: {
// Static
state_topic: false,
temperature_unit: 'C',
// Setpoint
temp_step: setpoint.value_step,
min_temp: setpoint.value_min.toString(),
max_temp: setpoint.value_max.toString(),
temperature_command_topic: setpoint.property,
temperature_state_template: `{{ value_json.${setpoint.property} }}`,
temperature_state_topic: true,
// Temperature
current_temperature_topic: true,
current_temperature_template: `{{ value_json.${temperature.property} }}`,
// Mode
mode_state_topic: true,
mode_state_template: `{{ value_json.${mode.property} }}`,
modes: mode.values,
mode_command_topic: true,
// State
action_topic: true,
action_template: `{% set values = ` +
`{'idle':'off','heat':'heating','cool':'cooling','fan only':'fan'}` +
` %}{{ values[value_json.${state.property}] }}`,
},
};
} else if (expose.type === 'lock') {
assert(!expose.endpoint, `Endpoint not supported for lock type`);
const state = expose.features.find((f) => f.name === 'state');
assert(state, 'No state found');
discoveryEntry = {
type: 'lock',
object_id: 'lock',
discovery_payload: {
command_topic: true,
value_template: '{{ value_json.state }}',
state_locked: 'LOCK',
state_unlocked: 'UNLOCK',
value_template: `{{ value_json.${state.property} }}`,
},
};

if (state.property === 'keypad_lockout') {
// deprecated: keypad_lockout is messy, but changing is breaking
discoveryEntry.discovery_payload.payload_lock = state.value_on;
discoveryEntry.discovery_payload.payload_unlock = state.value_off;
discoveryEntry.discovery_payload.state_topic = true;
discoveryEntry.object_id = 'keypad_lock';
} else {
discoveryEntry.discovery_payload.state_locked = state.value_on;
discoveryEntry.discovery_payload.state_unlocked = state.value_off;
}

if (state.property !== 'state') {
discoveryEntry.discovery_payload.command_topic_postfix = state.property;
}
} else if (expose.type === 'cover') {
assert(!expose.endpoint, `Endpoint not supported for cover type`);
const hasPosition = expose.features.find((e) => e.name === 'position');
Expand Down Expand Up @@ -582,6 +576,7 @@ class HomeAssistant extends Extension {
requested_brightness_percent: {icon: 'mdi:brightness-5'},
eco2: {icon: 'mdi:molecule-co2'},
co2: {icon: 'mdi:molecule-co2'},
local_temperature: {device_class: 'temperature'},
};

assert(!expose.endpoint, `Endpoint not supported for numeric type`);
Expand Down
6 changes: 3 additions & 3 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"winston-syslog": "^2.4.4",
"ws": "^7.3.1",
"zigbee-herdsman": "0.13.26",
"zigbee-herdsman-converters": "12.0.224",
"zigbee-herdsman-converters": "12.0.225",
"zigbee2mqtt-frontend": "0.2.68"
},
"devDependencies": {
Expand Down

0 comments on commit 2ee3b5f

Please sign in to comment.