Skip to content

Commit

Permalink
Docs based on exposes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Nov 21, 2020
1 parent 36bc3d3 commit ad306e8
Show file tree
Hide file tree
Showing 1,019 changed files with 25,073 additions and 2,049 deletions.
2 changes: 2 additions & 0 deletions docgen/device_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
const utils = require('./utils');
const notes = require('./device_page_notes');
const exposes = require('./device_page_exposes');
const YAML = require('json2yaml');
const HomeassistantExtension = require('zigbee2mqtt/lib/extension/homeassistant');
const homeassistant = new HomeassistantExtension(null, null, null, null, {on: () => {}});
Expand Down Expand Up @@ -61,6 +62,7 @@ ${device.hasOwnProperty('ota') && ['AC01353010G'].includes(device.model) === fal
## OTA updates
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:
Expand Down
87 changes: 87 additions & 0 deletions docgen/device_page_exposes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
const access = {
STATE: 1,
SET: 2,
STATE_SET: 3,
GET: 4,
STATE_GET: 5,
ALL: 7,
};

function generate(definition) {
return `
## Exposes
${definition.exposes.map((e) => getExposeDocs(e)).join('\n\n')}
`;
}

function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}

function getExposeDocs(expose) {
const lines = [];
const title = [];
if (expose.name) title.push(expose.type);
if (expose.endpoint) title.push(`${expose.endpoint} endpoint`);
lines.push(`### ${capitalizeFirstLetter(expose.name ? expose.name : expose.type)} ${title.length > 0 ? `(${title.join(', ')})` : ''}`);

if (['numeric', 'binary', 'text', 'enum'].includes(expose.type)) {
if (expose.description) {
lines.push(expose.description + '.');
}

if (expose.access & access.STATE) {
lines.push(`Value can be found in the published state on the \`${expose.property}\` property.`);
} else {
lines.push(`Value will **not** be published in the state.`);
}

if (expose.access === access.STATE) {
lines.push(`It's not possible to read (\`/get\`) or write (\`/set\`) this value.`);
} else {
if (expose.access & access.GET) {
lines.push(`To read (\`/get\`) the value publish a message to topic \`zigbee2mqtt/[FRIENDLY_NAME]/get\` with payload \`{"${expose.property}": ""}\`.`);
} else {
lines.push(`It's not possible to read (\`/get\`) this value.`);
}
if (expose.access & access.SET) {
lines.push(`To write (\`/set\`) a value publish a message to topic \`zigbee2mqtt/[FRIENDLY_NAME]/set\` with payload \`{"${expose.property}": NEW_VALUE}\`.`);
} else {
lines.push(`It's not possible to write (\`/set\`) this value.`);
}
}

if (expose.type === 'numeric') {
if (expose.hasOwnProperty('value_max') && expose.hasOwnProperty('value_max')) {
lines.push(`The minimimal value is \`${expose.value_min}\` and the maximum value is \`${expose.value_max}\`.`);
}

if (expose.unit) {
lines.push(`The unit of this value is \`${expose.unit}\`.`);
}
}

if (expose.type === 'binary') {
if (expose.hasOwnProperty('value_on') && expose.hasOwnProperty('value_off')) {
lines.push(`If value equals \`${expose.value_on}\` ${expose.name} is ON, if \`${expose.value_off}\` OFF.`);
}
}

if (expose.type === 'enum') {
lines.push(`The possible values are: ${expose.values.map((e) => `\`${e}\``).join(', ')}.`);
}
} else if (expose.type === 'switch') {
const state = expose.features.find((e) => e.name === 'state');
lines.push(`The current state of this switch is in the published state under the \`${state.property}\` property (value is \`${state.value_on}\` or \`${state.value_off}\`).`);
lines.push(`To control this switch publish a message to topic \`zigbee2mqtt/[FRIENDLY_NAME]/set\` with payload \`{"${state.property}": "${state.value_on}"}\`, \`{"${state.property}": "${state.value_off}"}\` or \`{"${state.property}": "${state.value_toggle}"}\`.`);
lines.push(`To read the current state of this switch publish a message to topic \`zigbee2mqtt/[FRIENDLY_NAME]/get\` with payload \`{"${state.property}": ""}\`.`);
} else {
lines.push('TODO');
}

return lines.join('\n');
}

module.exports = {
generate,
};
19 changes: 19 additions & 0 deletions docs/devices/046677476816.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@ Note that this value is overridden if a `transition` value is present in the MQT
## OTA updates
This device supports OTA updates, for more information see [OTA updates](../information/ota_updates.md).


## Exposes
### Light
TODO

### Effect (enum)
Triggers an effect on the light (e.g. make light blink for a few seconds).
Value will **not** be published in the state.
It's not possible to read (`/get`) this value.
To write (`/set`) a value publish a message to topic `zigbee2mqtt/[FRIENDLY_NAME]/set` with payload `{"effect": NEW_VALUE}`.
The possible values are: `blink`, `breathe`, `okay`, `channel_change`, `finish_effect`, `stop_effect`.

### Linkquality (numeric)
Link quality (signal strength).
Value can be found in the published state on the `linkquality` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The minimimal 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:
Expand Down
19 changes: 19 additions & 0 deletions docs/devices/046677551780.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@ Note that this value is overridden if a `transition` value is present in the MQT
## OTA updates
This device supports OTA updates, for more information see [OTA updates](../information/ota_updates.md).


## Exposes
### Light
TODO

### Effect (enum)
Triggers an effect on the light (e.g. make light blink for a few seconds).
Value will **not** be published in the state.
It's not possible to read (`/get`) this value.
To write (`/set`) a value publish a message to topic `zigbee2mqtt/[FRIENDLY_NAME]/set` with payload `{"effect": NEW_VALUE}`.
The possible values are: `blink`, `breathe`, `okay`, `channel_change`, `finish_effect`, `stop_effect`.

### Linkquality (numeric)
Link quality (signal strength).
Value can be found in the published state on the `linkquality` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The minimimal 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:
Expand Down
14 changes: 14 additions & 0 deletions docs/devices/046677552343.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ Note: if `hue_power_on_behavior` is set to `off`, then the only way to turn the
## OTA updates
This device supports OTA updates, for more information see [OTA updates](../information/ota_updates.md).


## Exposes
### Switch
The current state of this switch is in the published state under the `state` property (value is `ON` or `OFF`).
To control this switch publish a message to topic `zigbee2mqtt/[FRIENDLY_NAME]/set` with payload `{"state": "ON"}`, `{"state": "OFF"}` or `{"state": "TOGGLE"}`.
To read the current state of this switch publish a message to topic `zigbee2mqtt/[FRIENDLY_NAME]/get` with payload `{"state": ""}`.

### Linkquality (numeric)
Link quality (signal strength).
Value can be found in the published state on the `linkquality` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The minimimal 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:
Expand Down
22 changes: 22 additions & 0 deletions docs/devices/064873.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,28 @@ description: "Integrate your Legrand 064873 via Zigbee2MQTT with whatever smart

None


## Exposes
### Battery (numeric)
Remaining battery in %.
Value can be found in the published state on the `battery` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The minimimal value is `0` and the maximum value is `100`.
The unit of this value is `%`.

### Action (enum)
Triggered action (e.g. a button click).
Value can be found in the published state on the `action` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The possible values are: `enter`, `leave`, `sleep`, `wakeup`, `center`.

### Linkquality (numeric)
Link quality (signal strength).
Value can be found in the published state on the `linkquality` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The minimimal 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:
Expand Down
14 changes: 14 additions & 0 deletions docs/devices/064888.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ description: "Integrate your Legrand 064888 via Zigbee2MQTT with whatever smart

None


## Exposes
### Switch
The current state of this switch is in the published state under the `state` property (value is `ON` or `OFF`).
To control this switch publish a message to topic `zigbee2mqtt/[FRIENDLY_NAME]/set` with payload `{"state": "ON"}`, `{"state": "OFF"}` or `{"state": "TOGGLE"}`.
To read the current state of this switch publish a message to topic `zigbee2mqtt/[FRIENDLY_NAME]/get` with payload `{"state": ""}`.

### Linkquality (numeric)
Link quality (signal strength).
Value can be found in the published state on the `linkquality` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The minimimal 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:
Expand Down
22 changes: 22 additions & 0 deletions docs/devices/067694.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@ description: "Integrate your Legrand 067694 via Zigbee2MQTT with whatever smart
The remote supports [binding](../information/binding) for toggle action.



## Exposes
### Battery (numeric)
Remaining battery in %.
Value can be found in the published state on the `battery` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The minimimal value is `0` and the maximum value is `100`.
The unit of this value is `%`.

### Action (enum)
Triggered action (e.g. a button click).
Value can be found in the published state on the `action` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The possible values are: `identify`, `on`, `off`, `toggle`.

### Linkquality (numeric)
Link quality (signal strength).
Value can be found in the published state on the `linkquality` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The minimimal 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:
Expand Down
19 changes: 19 additions & 0 deletions docs/devices/067771.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@ Example of MQTT message payload to Identify the switch. This shouuld be sent to
```



## Exposes
### Light
TODO

### Effect (enum)
Triggers an effect on the light (e.g. make light blink for a few seconds).
Value will **not** be published in the state.
It's not possible to read (`/get`) this value.
To write (`/set`) a value publish a message to topic `zigbee2mqtt/[FRIENDLY_NAME]/set` with payload `{"effect": NEW_VALUE}`.
The possible values are: `blink`, `breathe`, `okay`, `channel_change`, `finish_effect`, `stop_effect`.

### Linkquality (numeric)
Link quality (signal strength).
Value can be found in the published state on the `linkquality` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The minimimal 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:
Expand Down
22 changes: 22 additions & 0 deletions docs/devices/067773.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,28 @@ Spanish models are branded as Legrand Valena Next, and models for this device de
The remote supports [binding](../information/binding).



## Exposes
### Battery (numeric)
Remaining battery in %.
Value can be found in the published state on the `battery` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The minimimal value is `0` and the maximum value is `100`.
The unit of this value is `%`.

### Action (enum)
Triggered action (e.g. a button click).
Value can be found in the published state on the `action` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The possible values are: `identify`, `on`, `off`, `brightness_move_up`, `brightness_move_down`, `brightness_stop`.

### Linkquality (numeric)
Link quality (signal strength).
Value can be found in the published state on the `linkquality` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The minimimal 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:
Expand Down
22 changes: 22 additions & 0 deletions docs/devices/067774.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ Model number depends on the country and the colour of the devices. For example:
The remote supports [binding](../information/binding) on each endpoint, so you can bind each button to a different device/group.
## Exposes
### Battery (numeric)
Remaining battery in %.
Value can be found in the published state on the `battery` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The minimimal value is `0` and the maximum value is `100`.
The unit of this value is `%`.

### Action (enum)
Triggered action (e.g. a button click).
Value can be found in the published state on the `action` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The possible values are: `identify`, `on`, `off`, `brightness_stop`, `brightness_move_up`, `brightness_move_down`.

### Linkquality (numeric)
Link quality (signal strength).
Value can be found in the published state on the `linkquality` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The minimimal 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:
Expand Down
41 changes: 41 additions & 0 deletions docs/devices/067775.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,47 @@ description: "Integrate your Legrand 067775 via Zigbee2MQTT with whatever smart

None


## Exposes
### Switch
The current state of this switch is in the published state under the `state` property (value is `ON` or `OFF`).
To control this switch publish a message to topic `zigbee2mqtt/[FRIENDLY_NAME]/set` with payload `{"state": "ON"}`, `{"state": "OFF"}` or `{"state": "TOGGLE"}`.
To read the current state of this switch publish a message to topic `zigbee2mqtt/[FRIENDLY_NAME]/get` with payload `{"state": ""}`.

### Action (enum)
Triggered action (e.g. a button click).
Value can be found in the published state on the `action` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The possible values are: `identify`.

### Power (numeric)
Instantaneous measured power.
Value can be found in the published state on the `power` property.
To read (`/get`) the value publish a message to topic `zigbee2mqtt/[FRIENDLY_NAME]/get` with payload `{"power": ""}`.
It's not possible to write (`/set`) this value.
The unit of this value is `W`.

### Voltage (numeric)
Measured electrical potential value.
Value can be found in the published state on the `voltage` property.
To read (`/get`) the value publish a message to topic `zigbee2mqtt/[FRIENDLY_NAME]/get` with payload `{"voltage": ""}`.
It's not possible to write (`/set`) this value.
The unit of this value is `V`.

### Current (numeric)
Instantaneous measured electrical current.
Value can be found in the published state on the `current` property.
To read (`/get`) the value publish a message to topic `zigbee2mqtt/[FRIENDLY_NAME]/get` with payload `{"current": ""}`.
It's not possible to write (`/set`) this value.
The unit of this value is `A`.

### Linkquality (numeric)
Link quality (signal strength).
Value can be found in the published state on the `linkquality` property.
It's not possible to read (`/get`) or write (`/set`) this value.
The minimimal 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:
Expand Down
Loading

0 comments on commit ad306e8

Please sign in to comment.