Skip to content

Commit

Permalink
Remove manual HA config
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Sep 30, 2021
1 parent 5ce3fd5 commit abd01d8
Show file tree
Hide file tree
Showing 1,542 changed files with 25,984 additions and 80,035 deletions.
68 changes: 1 addition & 67 deletions docgen/device_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
const utils = require('./utils');
const notes = require('./device_page_notes');
const exposes = require('./device_page_exposes');
const YAML = require('json2yaml');
const HomeassistantExtension = require('zigbee2mqtt/dist/extension/homeassistant');
const homeassistant = new HomeassistantExtension(null, null, null, null, {on: () => {}});
const assert = require('assert');
const devices = require('zigbee2mqtt/node_modules/zigbee-herdsman-converters').devices;
const devices = require('zigbee-herdsman-converters').devices;
const path = require('path');
const imageBase = path.join(__dirname, '..', 'docs', 'images', 'devices');

Expand Down Expand Up @@ -65,11 +62,6 @@ ${device.hasOwnProperty('ota') && ['AC01353010G'].includes(device.model) === fal
This device supports OTA updates, for more information see [OTA updates](../information/ota_updates.md).
` : ''}
${exposes.generate(device)}
## Manual Home Assistant configuration
Although Home Assistant integration through [MQTT discovery](../integration/home_assistant) is preferred,
manual integration is possible with the following configuration:
${getHomeAssistantConfig(device)}
`;
}

Expand Down Expand Up @@ -123,64 +115,6 @@ ${n.note}`;
return note === '' ? 'None' : note;
}

function getHomeAssistantConfig(device) {
let configuration = `
{% raw %}
\`\`\`yaml
`;
const configurations = homeassistant.getConfigs({definition: device, settings: {}, type: 'device'});

if (configurations) {
configurations.forEach((d, i) => {
configuration += getHomeassistantConfigForConfiguration(d);
if (configurations.length > 1 && i < configurations.length - 1) {
configuration += '\n';
}
});

configuration += '```\n';
configuration += '{% endraw %}\n\n';
}

return configuration;
}

function getHomeassistantConfigForConfiguration(device) {
const payload = {
platform: 'mqtt',
state_topic: 'zigbee2mqtt/<FRIENDLY_NAME>',
availability_topic: 'zigbee2mqtt/bridge/state',
...device.discovery_payload,
};

if (payload.command_topic) {
if (payload.command_topic_prefix) {
payload.command_topic = `zigbee2mqtt/<FRIENDLY_NAME>/${payload.command_topic_prefix}/set`;
} else {
payload.command_topic = `zigbee2mqtt/<FRIENDLY_NAME>/set`;
}
}

delete payload.command_topic_prefix;

if (!payload.state_topic) {
delete payload.state_topic;
}

if (payload.position_topic) {
payload.position_topic = 'zigbee2mqtt/<FRIENDLY_NAME>';
}

if (payload.set_position_topic) {
payload.set_position_topic = 'zigbee2mqtt/<FRIENDLY_NAME>/set';
}

let yml = YAML.stringify([payload]);
yml = yml.replace(/(-) \n {4}/g, '- ');
yml = yml.replace('---', `${device.type}:`);
return yml;
}

module.exports = {
generate,
};
2 changes: 1 addition & 1 deletion docgen/docgen.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs');
const path = require('path');
const devices = require('zigbee2mqtt/node_modules/zigbee-herdsman-converters').devices;
const devices = require('zigbee-herdsman-converters').devices;
const utils = require('./utils');

const base = path.join(__dirname, '..', 'docs');
Expand Down
2 changes: 1 addition & 1 deletion docgen/supported-devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This script generates the supported devices page.
*/

const devices = [...require('zigbee2mqtt/node_modules/zigbee-herdsman-converters').devices];
const devices = [...require('zigbee-herdsman-converters').devices];
const path = require('path');
const imageBase = path.join(__dirname, '..', 'docs', 'images', 'devices');

Expand Down
37 changes: 0 additions & 37 deletions docs/devices/0140302.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,40 +68,3 @@ It's not possible to read (`/get`) or write (`/set`) this value.
The minimal value is `0` and the maximum value is `255`.
The unit of this value is `lqi`.

## Manual Home Assistant configuration
Although Home Assistant integration through [MQTT discovery](../integration/home_assistant) is preferred,
manual integration is possible with the following configuration:


{% raw %}
```yaml
light:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
brightness: true
schema: "json"
command_topic: "zigbee2mqtt/<FRIENDLY_NAME>/set"
brightness_scale: 254
effect: true
effect_list:
- "blink"
- "breathe"
- "okay"
- "channel_change"
- "finish_effect"
- "stop_effect"

sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{{ value_json.linkquality }}"
unit_of_measurement: "lqi"
enabled_by_default: false
icon: "mdi:signal"
state_class: "measurement"
```
{% endraw %}
200 changes: 0 additions & 200 deletions docs/devices/014G2461.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,203 +163,3 @@ It's not possible to read (`/get`) or write (`/set`) this value.
The minimal value is `0` and the maximum value is `255`.
The unit of this value is `lqi`.

## Manual Home Assistant configuration
Although Home Assistant integration through [MQTT discovery](../integration/home_assistant) is preferred,
manual integration is possible with the following configuration:


{% raw %}
```yaml
sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{{ value_json.battery }}"
unit_of_measurement: "%"
device_class: "battery"
state_class: "measurement"

switch:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{{ value_json.keypad_lockout }}"
payload_on: "lock1"
payload_off: "unlock"
command_topic: "zigbee2mqtt/<FRIENDLY_NAME>/set"
command_topic_postfix: "keypad_lockout"

binary_sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{{ value_json.mounted_mode_active }}"
payload_on: true
payload_off: false

switch:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{% if value_json.mounted_mode_control %} true {% else %} false {% endif %}"
payload_on: "true"
payload_off: "false"
command_topic: "zigbee2mqtt/<FRIENDLY_NAME>/set"
command_topic_postfix: "mounted_mode_control"

switch:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{% if value_json.thermostat_vertical_orientation %} true {% else %} false {% endif %}"
payload_on: "true"
payload_off: "false"
command_topic: "zigbee2mqtt/<FRIENDLY_NAME>/set"
command_topic_postfix: "thermostat_vertical_orientation"

sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{{ value_json.viewing_direction }}"

switch:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{% if value_json.heat_available %} true {% else %} false {% endif %}"
payload_on: "true"
payload_off: "false"
command_topic: "zigbee2mqtt/<FRIENDLY_NAME>/set"
command_topic_postfix: "heat_available"

binary_sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{{ value_json.heat_required }}"
payload_on: true
payload_off: false

binary_sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{{ value_json.setpoint_change_source }}"
payload_on: 0
payload_off: 1

climate:
- platform: "mqtt"
availability_topic: "zigbee2mqtt/bridge/state"
temperature_unit: "C"
temp_step: 0.5
min_temp: "5"
max_temp: "32"
current_temperature_topic: true
current_temperature_template: "{{ value_json.local_temperature }}"
mode_state_topic: true
mode_state_template: "{{ value_json.system_mode }}"
modes:
- "heat"
mode_command_topic: true
action_topic: true
action_template: "{% set values = {'idle':'off','heat':'heating','cool':'cooling','fan only':'fan'} %}{{ values[value_json.running_state] }}"
temperature_command_topic: "occupied_heating_setpoint"
temperature_state_template: "{{ value_json.occupied_heating_setpoint }}"
temperature_state_topic: true

sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{{ value_json.external_measured_room_sensor }}"

sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{{ value_json.window_open_internal }}"

switch:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{% if value_json.window_open_external %} true {% else %} false {% endif %}"
payload_on: "true"
payload_off: "false"
command_topic: "zigbee2mqtt/<FRIENDLY_NAME>/set"
command_topic_postfix: "window_open_external"

sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{{ value_json.day_of_week }}"
enabled_by_default: false

select:
- platform: "mqtt"
state_topic: true
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{{ value_json.day_of_week }}"
command_topic: "zigbee2mqtt/<FRIENDLY_NAME>/set"
command_topic_postfix: "day_of_week"
options:
- "sunday"
- "monday"
- "tuesday"
- "wednesday"
- "thursday"
- "friday"
- "saturday"
- "away_or_vacation"

sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{{ value_json.trigger_time }}"

sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{{ value_json.algorithm_scale_factor }}"

sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{{ value_json.load_estimate }}"

sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
value_template: "{{ value_json.linkquality }}"
unit_of_measurement: "lqi"
enabled_by_default: false
icon: "mdi:signal"
state_class: "measurement"

sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
icon: "mdi:update"
value_template: "{{ value_json['update']['state'] }}"
enabled_by_default: false

binary_sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
payload_on: true
payload_off: false
value_template: "{{ value_json.update_available}}"
enabled_by_default: false
```
{% endraw %}
Loading

0 comments on commit abd01d8

Please sign in to comment.