-
Notifications
You must be signed in to change notification settings - Fork 162
Configuration V2
The software is configured using a single YAML config file. This document details the config options for each section and provides examples.
-
mqtt gpio_modulessensor_modulesstream_modules-
digital_inputs -
digital_outputs -
sensor_inputs logging
Type: dict
Required: yesContains the configuration data used for connecting to an MQTT server.
Example:
mqtt:
host: test.mosquitto.org
port: 8883
topic_prefix: mqtt_io
ha_discovery:
enabled: yes
tls:
enabled: yes
ca_certs: mosquitto.org.crt
certfile: client.crt
keyfile: client.keyType: string
Required: yesHost name or IP address of the MQTT server.
Type: integer
Required: no
Minimum value: 1
Minimum value: 65535
Default: 1883Port number to connect to on the MQTT server.
Type: string
Required: no
Default: ''Username to authenticate with on the MQTT server.
Type: string
Required: no
Default: ''Password to authenticate with on the MQTT server.
Type: string
Required: no
Default: ''MQTT client ID to use on the MQTT server.
Type: string
Required: no
Default: ''Prefix to use for all topics.
For example, a
topic_prefixofhome/livingroomwould make a digital input called "doorbell" publish its changes to thehome/livingroom/input/doorbelltopic.
Type: boolean
Required: no
Default: falseWhether or not to start a clean MQTT session on every MQTT connection.
Type: string
Required: no
Allowed:
- '3.1'
- 3.1.1
Default: 3.1.1Version of the MQTT protocol to use.
This renders in the documentation as a float, but should always be set within quotes.
Type: integer
Required: no
Unit: seconds
Minimum value: 1
Default: 10How frequently in seconds to send ping packets to the MQTT server.
Type: string
Required: no
Default: statusTopic on which to send messages about the running status of this software.
Sends the payloads configured in
status_payload_running,status_payload_stoppedandstatus_payload_dead.
Type: string
Required: no
Default: runningPayload to send on the status topic when the software is running.
Type: string
Required: no
Default: stoppedPayload to send on the status topic when the software has exited cleanly.
Type: string
Required: no
Default: deadPayload to send on the status topic when the software has exited unexpectedly.
Uses MQTT Last Will and Testament to make the server automatically send this payload if our connection fails.
Type: string
Required: no
Default: mqtt_io.mqtt.asyncio_mqttMQTT Client implementation module path.
There's currently only one implementation, which uses the asyncio-mqtt client.
Type: dict
Required: noType: boolean
Required: yesEnable Home Assistant MQTT discovery of our configured devices.
Type: string
Required: no
Default: homeassistantPrefix for the Home Assistant MQTT discovery topic.
Type: string
Required: no
Default: MQTT IOName to identify this "device" in Home Assistant.
Type: dict
Required: noTLS/SSL settings for connecting to the MQTT server over an encrypted connection.
Example:
mqtt:
host: localhost
tls:
enabled: yes
ca_certs: mosquitto.org.crt
certfile: client.crt
keyfile: client.keyType: boolean
Required: yesEnable a secure connection to the MQTT server.
Most of these options map directly to the
tls_set()arguments on the Paho MQTT client.
Type: string
Required: noPath to the Certificate Authority certificate files that are to be treated as trusted by this client. More info
Type: string
Required: noPath to the PEM encoded client certificate. More info
Type: string
Required: noPath to the PEM encoded client private key. More info
Type: string
Required: no
Allowed:
- CERT_NONE
- CERT_OPTIONAL
- CERT_REQUIRED
Default: CERT_REQUIREDDefines the certificate requirements that the client imposes on the MQTT server. More info
By default this is
CERT_REQUIRED, which means that the broker must provide a certificate.
Type: string
Required: noSpecifies the version of the SSL/TLS protocol to be used. More info
By default the highest TLS version is detected.
Type: string
Required: noWhich encryption ciphers are allowable for this connection. More info
Type: boolean
Required: no
Default: falseConfigure verification of the server hostname in the server certificate. More info
If set to true, it is impossible to guarantee that the host you are connecting to is not impersonating your server. This can be useful in initial server testing, but makes it possible for a malicious third party to impersonate your server through DNS spoofing, for example. Do not use this function in a real system. Setting value to true means there is no point using encryption.
Type: list
Required: no
Default: []List of GPIO modules to configure for use with inputs and/or outputs.
Some modules require extra config entries, specified by the modules themselves. Until the documentation is written for the individual modules, please refer to the
CONFIG_SCHEMAvalue of the module's code in the repository. TODO: Link this to the pending wiki pages on each module's requirements.
Example:
gpio_modules:
- name: rpi_gpio
module: raspberrypi
- name: pcf
module: pcf8574
i2c_bus_num: 1
chip_addr: 0x20Type: dict
Required: no
Unlisted entries accepted: yesType: string
Required: yesYour name for this configuration of the module. Will be referred to by entries
in the digital_inputs and/or digital_outputs sections.
Type: string
Required: yesName of the module in the code. This is listed in the README's "Supported Hardware" section in brackets.
Type: boolean
Required: no
Default: trueWhether to run the module's cleanup() method on exit.
Type: list
Required: no
Default: []List of sensor modules to configure for use with sensor inputs.
Some modules require extra config entries, specified by the modules themselves. Until the documentation is written for the individual modules, please refer to the
CONFIG_SCHEMAvalue of the module's code in the repository. TODO: Link this to the pending wiki pages on each module's requirements.
Example:
sensor_modules:
- name: dht
module: dht22
type: AM2302
pin: 4
- name: ds
module: ds18b
type: DS18S20
address: 000803702e49Type: dict
Required: no
Unlisted entries accepted: yesType: string
Required: yesYour name for this configuration of the module. Will be referred to by entries
in the sensor_inputs section.
Type: string
Required: yesName of the module in the code. This is listed in the README's "Supported Hardware" section in brackets.
Type: boolean
Required: no
Default: trueWhether to run the module's cleanup() method on exit.
Type: list
Required: no
Default: []List of stream modules to configure.
Some modules require extra config entries, specified by the modules themselves. Until the documentation is written for the individual modules, please refer to the
CONFIG_SCHEMAvalue of the module's code in the repository. TODO: Link this to the pending wiki pages on each module's requirements.
Example:
stream_modules:
- name: network_switch
module: serial
device: /dev/ttyUSB1
baud: 115200
interval: 10
- name: ups
module: serial
type: /dev/ttyUSB0
baud: 9600
interval: 1Type: dict
Required: no
Unlisted entries accepted: yesType: string
Required: yesYour name for this configuration of the module. Will be used in the topic on which the stream's data is published and the topic on which messages can be sent for writing to the stream.
Type: string
Required: yesName of the module in the code. This is listed in the README's "Supported Hardware" section in brackets.
Type: boolean
Required: no
Default: trueWhether to run the module's cleanup() method on exit.
Type: boolean
Required: no
Default: falseWhether to set the retain flag on MQTT messages publishing data received
from the stream.
Type: float
Required: no
Unit: seconds
Minimum value: 0.01
Default: 60How long to wait between polling the stream for new data.
Type: boolean
Required: no
Default: trueWhether to poll this stream for incoming data and publish it on an MQTT topic.
Type: boolean
Required: no
Default: trueWhether to subscribe to MQTT messages on a topic and write messages received on it to the stream.
Type: list
Required: no
Default: []List of digital inputs to configure.
Some modules require extra config entries, specified by the modules themselves. Until the documentation is written for the individual modules, please refer to the
PIN_SCHEMAandINPUT_SCHEMAvalues of the module's code in the repository. TODO: Link this to the pending wiki pages on each module's requirements.
Example:
gpio_modules:
- name: rpi
module: raspberrypi
digital_inputs:
- name: gpio0
module: rpi
pin: 0
- name: gpio1
module: rpi
pin: 1Type: dict
Required: no
Unlisted entries accepted: yesType: string
Required: yesName of the input. Used in the MQTT topic when publishing input changes.
The topic that input changes will be published to is:
<mqtt.topic_prefix>/input/<this name>
Type: string
Required: yesName of the module configured in gpio_modules that this input is attached to.
Type:
- string
- integer
Required: yesWhich of the GPIO module's pins this input refers to.
Depending on the GPIO module's implementation, this can be either a string or an integer.
Type: string
Required: no
Default: 'ON'Payload to be sent when the input changes to what is considered to be "on".
See inverted below for the definition of "on" and "off".
Make sure to avoid YAML's automatic boolean type conversion when setting this option by surrounding potential booleans with quotes. See the "Regexp" section of the YAML bool docs for all of the values that will be parsed as boolean.
Type: string
Required: no
Default: 'OFF'Payload to be sent when the input changes to what is considered to be "off".
See inverted below for the definition of "on" and "off".
Make sure to avoid YAML's automatic boolean type conversion when setting this option by surrounding potential booleans with quotes. See the "Regexp" section of the YAML bool docs for all of the values that will be parsed as boolean.
Type: boolean
Required: no
Default: falseInvert the logic level so that "low" levels are considered to be "on" and "high" levels are considered "off".
This can be useful for when an input is pulled "high" with a resistor and a device (like a button or another IC) connects it to ground when it's "active".
Type: boolean
Required: no
Default: falseEnable the pull-up resistor for this input so that the logic level is pulled "high" by default.
Not all GPIO modules support pull-up resistors.
Type: boolean
Required: no
Default: falseEnable the pull-down resistor for this input so that the logic level is pulled "low" by default.
Not all GPIO modules support pull-down resistors.
Type: string
Required: no
Allowed:
- rising
- falling
- bothConfigure this pin to trigger an interrupt when the logic level is "rising", "falling" or "both".
Not all GPIO modules support interrupts, and those that do may do so in various ways. TODO: Add link to interrupt documentation.
Type: list
Required: noList of other pin names that this pin is an interrupt for.
This is generally used on GPIO modules that provide software callbacks on interrupts, so that we can attach another "remote" module's interrupt output pin (one that changes logic level when one of its pins triggers an interrupt) to this input and use the callback to get the value of the "remote" pin and publish it on MQTT.
TODO: Add link to interrupt documentation.
Type: string
Required: yesType: integer
Required: no
Unit: milliseconds
Minimum value: 1
Default: 100Don't trigger interrupts more frequently than once per bouncetime.
Type: boolean
Required: no
Default: falseSet the retain flag on MQTT messages published on input change.
Type: float
Required: no
Unit: seconds
Default: 0.1How long to wait between checking the value of this input.
When the pin is configured as an interrupt, the pin is no longer polled. The only exception to this is if the pin is configured as an interrupt for another pin. In this case, whether or not we poll is decided by the
poll_when_interrupt_forsetting below.
Type: boolean
Required: no
Default: truePoll this pin when it's configured as an interrupt for another pin.
Polling the pin when it's configured as an interrupt for another pin is useful in order to make sure that if we somehow miss an interrupt on this pin (the remote module's interrupt output pin goes low ("triggered")), we don't end up stuck in that state where we don't handle the remote module's interrupt at all. If we poll the "triggered" value on this pin and our interrupt handling hasn't dealt with it, then we'll handle it here.
Type: dict
Required: no
Unlisted entries accepted: yesConfigures the Home Assistant MQTT discovery for this pin.
Any values entered into this section will be sent as part of the discovery config payload. See the above link for documentation.
Example:
digital_inputs:
- name: livingroom_motion
module: rpi
ha_discovery:
component: binary_sensor
name: Living Room Motion
device_class: motionType: string
Required: no
Default: binary_sensorType of component to report this input as to Home Assistant.
Type: list
Required: no
Default: []List of digital outputs to configure.
Some modules require extra config entries, specified by the modules themselves. Until the documentation is written for the individual modules, please refer to the
PIN_SCHEMAandOUTPUT_SCHEMAvalues of the module's code in the repository. TODO: Link this to the pending wiki pages on each module's requirements.
Example:
gpio_modules:
- name: rpi
module: raspberrypi
digital_outputs:
- name: gpio0
module: rpi
pin: 0
- name: gpio1
module: rpi
pin: 1Type: dict
Required: no
Unlisted entries accepted: yesType: string
Required: yesName of the output. Used in the MQTT topics that are subscribed to in order to change the output value according to received MQTT messages, as well as in the MQTT topic for publishing output changes.
The topics subscribed to for each output are:
<mqtt.topic_prefix>/output/<this name>/set<mqtt.topic_prefix>/output/<this name>/set_on_ms<mqtt.topic_prefix>/output/<this name>/set_off_ms
The topic that output changes will be published to is:
<mqtt.topic_prefix>/output/<this name>
Type: string
Required: yesName of the module configured in gpio_modules that this output is attached to.
Type:
- string
- integer
Required: yesWhich of the GPIO module's pins this output refers to.
Depending on the GPIO module's implementation, this can be either a string or an integer.
Type: string
Required: no
Default: 'ON'Payload to consider as "on" when received to the /set topic for this output.
See inverted below for the definition of "on" and "off".
Make sure to avoid YAML's automatic boolean type conversion when setting this option by surrounding potential booleans with quotes. See the "Regexp" section of the YAML bool docs for all of the values that will be parsed as boolean.
Type: string
Required: no
Default: 'OFF'Payload to consider as "off" when received to the /set topic for this output.
See inverted below for the definition of "on" and "off".
Make sure to avoid YAML's automatic boolean type conversion when setting this option by surrounding potential booleans with quotes. See the "Regexp" section of the YAML bool docs for all of the values that will be parsed as boolean.
Type: boolean
Required: no
Default: falseInvert the logic level so that "low" levels are considered to be "on" and "high" levels are considered "off".
This can be useful for when an output turns something on when its output is "low".
Type: integer
Required: no
Unit: millisecondsHow long to set an output to the desired value on receipt of an MQTT message
to the /set topic before then setting it back to the opposite value.
This may be useful if the output controls a device where leaving the ouput "on" for too long would be detrimental. Using this option means that you don't have to rely on a second "off" message getting through MQTT for the output to return to a safe state.
Type: string
Required: no
Allowed:
- high
- lowSet the output to an initial "high" or "low" state when the software starts.
Type: boolean
Required: no
Default: falseWhether to publish an MQTT message for the initial "high" or "low" state set above.
Type: boolean
Required: no
Default: falseSet the retain flag on MQTT messages published on output change.
Type: dict
Required: no
Unlisted entries accepted: yesConfigures the Home Assistant MQTT discovery for this pin.
Any values entered into this section will be sent as part of the discovery config payload. See the above link for documentation.
Example:
digital_outputs:
- name: garage_door1
module: rpi
ha_discovery:
component: switch
name: Ferrari Garage Door
device_class: garage_doorType: string
Required: no
Default: switchType of component to report this output as to Home Assistant.
Type: list
Required: no
Default: []List of sensor inputs to configure.
Some modules require extra config entries, specified by the modules themselves. Until the documentation is written for the individual modules, please refer to the
MODULE_SCHEMAvalues of the module's code in the repository. TODO: Link this to the pending wiki pages on each module's requirements.
Example:
sensor_modules:
- name: dht
module: dht22
type: AM2302
pin: 4
sensor_inputs:
- name: workshop_temp
module: dht
type: temperature
interval: 30
- name: workshop_humidity
module: dht
type: humidity
interval: 60Type: dict
Required: no
Unlisted entries accepted: yesType: string
Required: yesName of the sensor. Used in the MQTT topic when publishing sensor values.
The topic that sensor values will be published to is:
<mqtt.topic_prefix>/sensor/<this name>
Type: string
Required: yesName of the module configured in sensor_modules that this sensor reading
comes from.
Type: boolean
Required: no
Default: falseSet the retain flag on MQTT messages published on sensor read.
Type: integer
Required: no
Unit: seconds
Minimum value: 1
Default: 60How long to wait between checking the value of this sensor.
Type: integer
Required: no
Minimum value: 0
Default: 2How many decimal places to round the sensor reading to.
Type: dict
Required: no
Unlisted entries accepted: yesConfigures the Home Assistant MQTT discovery for this sensor.
Any values entered into this section will be sent as part of the discovery config payload. See the above link for documentation.
Example:
sensor_inputs:
- name: workshop_temp
module: dht
type: temperature
ha_discovery:
name: Workshop Temperature
device_class: temperature
- name: workshop_humidity
module: dht
type: humidity
ha_discovery:
name: Workshop Humidity
device_class: humidityType: string
Required: no
Default: sensorType of component to report this sensor as to Home Assistant.
Type: integer
Required: no
Minimum value: 1How long after receiving a sensor update to declare it invalid.
Defaults to
interval* 2 + 5
Type: dict
Required: no
Unlisted entries accepted: yes
Default:
formatters:
default:
datefmt: '%Y-%m-%d %H:%M:%S'
format: '%(asctime)s %(name)s [%(levelname)s] %(message)s'
handlers:
console:
class: logging.StreamHandler
formatter: default
level: INFO
loggers:
mqtt_io:
handlers:
- console
level: INFO
propagate: true
version: 1Config to pass directly to Python's logging module to influence the logging output of the software.