From 9c6e176e4cefe8c0d6f8dd190bdc8653fd739d43 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 18 Dec 2015 13:05:57 +0100 Subject: [PATCH] Fix #126 (Use real templates) --- source/_components/automation.markdown | 2 ++ source/_components/binary_sensor.mqtt.markdown | 4 ++-- source/_components/device_tracker.mqtt.markdown | 2 +- source/_components/light.mqtt.markdown | 2 +- source/_components/rollershutter.mqtt.markdown | 3 ++- source/_components/sensor.arest.markdown | 7 ++----- source/_components/sensor.command_sensor.markdown | 2 +- source/_components/sensor.mqtt.markdown | 2 +- source/_components/sensor.rest.markdown | 4 ++-- source/_components/switch.mqtt.markdown | 5 +++-- source/_components/switch.rest.markdown | 2 +- 11 files changed, 18 insertions(+), 17 deletions(-) diff --git a/source/_components/automation.markdown b/source/_components/automation.markdown index 8600a672f30..d90887ee8af 100644 --- a/source/_components/automation.markdown +++ b/source/_components/automation.markdown @@ -109,6 +109,8 @@ automation: trigger: platform: numeric_state entity_id: sensor.temperature + # Optional + value_template: '{% raw %}{{ state.attributes.battery }}{% endraw %}' # At least one of the following required above: 17 below: 25 diff --git a/source/_components/binary_sensor.mqtt.markdown b/source/_components/binary_sensor.mqtt.markdown index 9961e4c618f..15a180fecd3 100644 --- a/source/_components/binary_sensor.mqtt.markdown +++ b/source/_components/binary_sensor.mqtt.markdown @@ -12,7 +12,7 @@ ha_category: Binary Sensor --- -This MQTT binary sensor implementation uses the MQTT message payload as the sensor value. If messages in this state_topic are published with *RETAIN* flag, the sensor will receive an instant update with the last known value. Otherwise, the initial state will be off. +This `mqtt` binary sensor implementation uses the MQTT message payload as the sensor value. If messages in this state_topic are published with *RETAIN* flag, the sensor will receive an instant update with the last known value. Otherwise, the initial state will be off. To use your MQTT binary sensor in your installation, add the following to your `configuration.yaml` file: @@ -25,7 +25,7 @@ binary_sensor: qos: 0 payload_on: "ON" payload_of: "OFF" - value_template: '{% raw %}{{ template }}{% endraw %}' + value_template: '{% raw %}{{ value.x }}{% endraw %}' ``` Configuration variables: diff --git a/source/_components/device_tracker.mqtt.markdown b/source/_components/device_tracker.mqtt.markdown index 2512bfbe875..70c71cdebe6 100644 --- a/source/_components/device_tracker.mqtt.markdown +++ b/source/_components/device_tracker.mqtt.markdown @@ -12,7 +12,7 @@ ha_category: Presence Detection --- -This platform allows you to detect presence by monitoring an MQTT topic for new locations. To use this platform, you specify a unique topic for each device. +The `mqtt` device tracker platform allows you to detect presence by monitoring an MQTT topic for new locations. To use this platform, you specify a unique topic for each device. To use this device tracker in your installation, add the following to your `configuration.yaml` file: diff --git a/source/_components/light.mqtt.markdown b/source/_components/light.mqtt.markdown index d9878214d0d..2efd163e0b4 100644 --- a/source/_components/light.mqtt.markdown +++ b/source/_components/light.mqtt.markdown @@ -12,7 +12,7 @@ ha_category: Light --- -The mqtt light platform let you control your MQTT enabled light. +The `mqtt` light platform let you control your MQTT enabled light. In an ideal scenario, the MQTT device will have a state topic to publish state changes. If these messages are published with RETAIN flag, the MQTT switch will receive an instant state update after subscription and will start with correct state. Otherwise, the initial state of the switch will be false/off. diff --git a/source/_components/rollershutter.mqtt.markdown b/source/_components/rollershutter.mqtt.markdown index 0127ce7d217..a9b92398d6e 100644 --- a/source/_components/rollershutter.mqtt.markdown +++ b/source/_components/rollershutter.mqtt.markdown @@ -27,6 +27,7 @@ motor: payload_open: "OPEN" payload_close: "CLOSE" payload_stop: "STOP" + value_template: '{% raw %}{{ value.x }}{% endraw %}' ``` Configuration variables: @@ -39,4 +40,4 @@ Configuration variables: - **payload_open** (*Optional*): The payload to open the rollershutter. Default is "OPEN". - **payload_close** (*Optional*): The payload to close the rollershutter. Default is "CLOSE". - **payload_stop** (*Optional*): The payload to stop the rollershutter. Default is "STOP". -- **state_format** (*Optional*): The state format to parse. Default is None (no parser). +- **value_template** (*Optional*): Defines a [template](/getting-started/templating/) to extract a value from the payload. diff --git a/source/_components/sensor.arest.markdown b/source/_components/sensor.arest.markdown index c6b908bb5e6..2b95d576628 100644 --- a/source/_components/sensor.arest.markdown +++ b/source/_components/sensor.arest.markdown @@ -31,8 +31,7 @@ sensor: A0: name: Pin 0 analog unit_of_measurement: "ca" - correction_factor: 0.01 - decimal_places: 1 + value_template: '{% raw %}{{ value_json.light }}{% endraw %}' 3: name: Pin 3 digital ``` @@ -47,8 +46,7 @@ Configuration variables: - **pins** array (*Optional*): List of pins to monitor. Analog pins need a leading **A** for the pin number. - **name** (*Optional*): The name of the variable you wish to monitor. - **unit_of_measurement** (*Optional*): Defines the unit of measurement of the sensor, if any. - - **correction_factor** (*Optional*): A float value to do some basic calculations. - - **decimal_places** (*Optional*): Number of decimal places of the value. + - **value_template** (*Optional*): Defines a [template](/getting-started/templating/) to extract a value from the payload. The variables in the `monitored_variables` array must be available in the response of the device. As a starting point you could use the one of the example sketches (eg. [Ethernet](https://raw.githubusercontent.com/marcoschwartz/aREST/master/examples/Ethernet/Ethernet.ino) for an Arduino with Ethernet shield). In those sketches are two variables (`temperature` and `humidity`) available which will act as endpoints. @@ -78,4 +76,3 @@ The root will give you a JSON response that contains all variables and their cur {"return_value": 34, "id": "sensor02", "name": "livingroom", "connected": true} ``` - diff --git a/source/_components/sensor.command_sensor.markdown b/source/_components/sensor.command_sensor.markdown index effa0606459..914ce66f8ff 100644 --- a/source/_components/sensor.command_sensor.markdown +++ b/source/_components/sensor.command_sensor.markdown @@ -22,7 +22,7 @@ sensor: command: SENSOR_COMMAND name: Command sensor unit_of_measurement: "°C" - value_template: '{% raw %}{{ template }}{% endraw %}' + value_template: '{% raw %}{{ value.x }}{% endraw %}' ``` Configuration variables: diff --git a/source/_components/sensor.mqtt.markdown b/source/_components/sensor.mqtt.markdown index ab022bdb293..71b6355428d 100644 --- a/source/_components/sensor.mqtt.markdown +++ b/source/_components/sensor.mqtt.markdown @@ -24,7 +24,7 @@ sensor: name: "MQTT Sensor" qos: 0 unit_of_measurement: "°C" - value_template: '{% raw %}{{ template }}{% endraw %}' + value_template: '{% raw %}{{ value.x }}{% endraw %}' ``` Configuration variables: diff --git a/source/_components/sensor.rest.markdown b/source/_components/sensor.rest.markdown index d039fb3f9f4..a7ffa015c44 100644 --- a/source/_components/sensor.rest.markdown +++ b/source/_components/sensor.rest.markdown @@ -11,7 +11,7 @@ ha_category: Sensor --- -The rest sensor platform is consuming a given endpoint which is exposed by a [RESTful API](https://en.wikipedia.org/wiki/Representational_state_transfer) of a device, an application, or a web service. The sensor has support for GET and POST requests. +The `rest` sensor platform is consuming a given endpoint which is exposed by a [RESTful API](https://en.wikipedia.org/wiki/Representational_state_transfer) of a device, an application, or a web service. The sensor has support for GET and POST requests. To enable this sensor, add the following lines to your `configuration.yaml` file for a GET request: @@ -22,7 +22,7 @@ sensor: resource: http://IP_ADDRESS/ENDPOINT method: GET name: REST GET sensor - value_template: '{% raw %}{{ template }}{% endraw %}' + value_template: '{% raw %}{{ value_json.x }}{% endraw %}' unit_of_measurement: "°C" ``` diff --git a/source/_components/switch.mqtt.markdown b/source/_components/switch.mqtt.markdown index 24849333339..88f42a36e66 100644 --- a/source/_components/switch.mqtt.markdown +++ b/source/_components/switch.mqtt.markdown @@ -11,6 +11,7 @@ logo: mqtt.png ha_category: Switch --- +The `mqtt` switch platform let you control your MQTT enabled light. In an ideal scenario, the MQTT device will have a state topic to publish state changes. If these messages are published with RETAIN flag, the MQTT switch will receive an instant state update after subscription and will start with correct state. Otherwise, the initial state of the switch will be false/off. @@ -31,7 +32,7 @@ switch: payload_on: "ON" payload_off: "OFF" optimistic: false - state_format: + value_template: '{% raw %}{{ value.x }}{% endraw %}' ``` Configuration variables: @@ -43,7 +44,7 @@ Configuration variables: - **payload_on** (*Optional*): The payload that represents enabled state. Default is "ON". - **payload_off** (*Optional*): The payload that represents disabled state. Default is "OFF". - **optimistic** (*Optional*): Flag that defines if switch works in optimistic mode. Default is true if no state topic defined, else false. -- **state_format** (*Optional*): Value to parse. +- **value_template** (*Optional*): Defines a [template](/getting-started/templating/) to extract a value from the payload.

Make sure that your topics match exact. `some-topic/` and `some-topic` are different topics. diff --git a/source/_components/switch.rest.markdown b/source/_components/switch.rest.markdown index 2342d6f80dd..ed7dfdc110c 100644 --- a/source/_components/switch.rest.markdown +++ b/source/_components/switch.rest.markdown @@ -11,7 +11,7 @@ ha_category: Switch --- -The rest switch platform allows you to control a given endpoint that supports a [RESTful API](https://en.wikipedia.org/wiki/Representational_state_transfer). The switch can get the state via GET and set the state via POST on a given REST resource. +The `rest` switch platform allows you to control a given endpoint that supports a [RESTful API](https://en.wikipedia.org/wiki/Representational_state_transfer). The switch can get the state via GET and set the state via POST on a given REST resource. To enable this switch, add the following lines to your `configuration.yaml` file: