diff --git a/docs/img/HA_discovery_new_switch.png b/docs/img/HA_discovery_new_switch.png new file mode 100644 index 0000000000..d46cfab422 Binary files /dev/null and b/docs/img/HA_discovery_new_switch.png differ diff --git a/docs/integrate/home_assistant.md b/docs/integrate/home_assistant.md index 50457c41a5..f899485e25 100644 --- a/docs/integrate/home_assistant.md +++ b/docs/integrate/home_assistant.md @@ -1,8 +1,19 @@ # Integrate Home Assistant + +Home Assistant provide the [MQTT integration](https://www.home-assistant.io/integrations/mqtt/) and through this integration it is possible to exploit and manage the messages published by OpenMqttGateway. + +Once this integration on home assistant is configured with the same mqtt broker, it is possible to create devices manually or through the autodiscovery function. + + ## Auto discovery -Home Assistant discovery is enabled by default on all binaries and platformio configurations except for UNO. With Arduino IDE please read the [advanced configuration section](../upload/advanced-configuration#auto-discovery) of the documentation. -First enable discovery on your MQTT integration in HASS. +From Home Assistant site + +> The discovery of MQTT devices will enable one to use MQTT devices with only minimal configuration effort on the side of Home Assistant. The configuration is done on the device itself and the topic used by the device. + +On OpenMqttGateway the Home Assistant discovery is enabled by default on all binaries and platformio configurations except for UNO. With Arduino IDE please read the [advanced configuration section](../upload/advanced-configuration#auto-discovery) of the documentation. Here are a few tips for activating discovery on Home Assistant, but for detailed configuration please refer to the Home Assistant website. + +Enable discovery on your MQTT integration in HASS. ![](../img/OpenMQTTGateway-Configuration-Home-Assistant-Discovery-Integration.png) @@ -22,6 +33,43 @@ OMG will use the auto discovery functionality of home assistant to create gatewa ![](../img/OpenMQTTGateway_Home_Assistant_MQTT_discovery.png) + +### Example with "DIGOO DG-HOSA 433MHz PIR Detector" + +With OpenMqttGateway [configured to receive RF signals](./setitup/rf.html) the messages are transmitted as indicated by [RCSwitch based gateway](./use/rf.html#rcswitch-based-gateway), so it is possible to receive a pulse every time the sensor discover a movement. + +With autodiscovery enabled, HomeAssistant will discover a new switch identified by the value field given in the mqtt argument. + + +![](../img/HA_discovery_new_switch.png) + + +With this configuration we receive from the broker only the close signal, which produces the change of state of the switch to "on". One way to reset the status is to setup one [automation](https://www.home-assistant.io/docs/automation/basics/) like this + +```yaml +alias: Reset Pirs +description: '' +trigger: + - platform: state + entity_id: + - switch.2708742 + to: 'on' +condition: [] +action: + - delay: + hours: 0 + minutes: 0 + seconds: 3 + milliseconds: 0 + - service: switch.turn_off + target: + entity_id: '{{ trigger.entity_id }}' +mode: parallel +max: 100 + +``` + + ## Manual integration examples From @123, @finity, @denniz03, @jrockstad, @anarchking diff --git a/main/ZgatewayRF.ino b/main/ZgatewayRF.ino index d9c897e577..54902d4073 100644 --- a/main/ZgatewayRF.ino +++ b/main/ZgatewayRF.ino @@ -42,7 +42,7 @@ void RFtoMQTTdiscovery(SIGNAL_SIZE_UL_ULL MQTTvalue) { //on the fly switch creat char val[11]; sprintf(val, "%lu", MQTTvalue); Log.trace(F("switchRFDiscovery" CR)); - char* switchRF[8] = {"switch", val, "", "", "", val, "", ""}; + char* switchRF[8] = {"switch", val, "", "", jsonVal, val, "", ""}; //component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement Log.trace(F("CreateDiscoverySwitch: %s" CR), switchRF[1]);