Skip to content

Commit c80d9b5

Browse files
Add mysensors notify platform (home-assistant#1736)
1 parent b01f700 commit c80d9b5

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
layout: page
3+
title: "MySensors Notify"
4+
description: "Instructions how to integrate MySensors notifications into Home Assistant."
5+
date: 2017-01-07 15:00 +0100
6+
sidebar: true
7+
comments: false
8+
sharing: true
9+
footer: true
10+
logo: mysensors.png
11+
ha_category: Notifications
12+
ha_release: 0.36
13+
ha_iot_class: "Local Push"
14+
---
15+
16+
Integrates MySensors notifications into Home Assistant. See the [main component] for configuration instructions.
17+
18+
Setting the `target` key in the service call will target the name of the MySensors device in Home Assistant. MySensors device names follow the notation: "[Sketch name] [Node id] [Child id]".
19+
20+
### {% linkable_title Automation example %}
21+
22+
```yaml
23+
...
24+
action:
25+
service: notify.mysensors
26+
data:
27+
message: Welcome home!
28+
target: 'TextSensor 254 1'
29+
```
30+
31+
The following sensor types are supported:
32+
33+
##### MySensors version 2.0 and higher
34+
35+
S_TYPE | V_TYPE
36+
----------------|--------------------------
37+
S_INFO | V_TEXT
38+
39+
For more information, visit the [api] page of MySensors.
40+
41+
### {% linkable_title Example sketch %}
42+
43+
```cpp
44+
/*
45+
* Documentation: http://www.mysensors.org
46+
* Support Forum: http://forum.mysensors.org
47+
*/
48+
49+
#define MY_DEBUG
50+
#define MY_RADIO_NRF24
51+
#define MY_REPEATER_FEATURE
52+
53+
#include <SPI.h>
54+
#include <MySensors.h>
55+
56+
#define SN "TextSensor"
57+
#define SV "1.0"
58+
#define CHILD_ID 1
59+
60+
MyMessage textMsg(CHILD_ID, V_TEXT);
61+
bool initialValueSent = false;
62+
63+
void setup(void) {
64+
}
65+
66+
void presentation() {
67+
sendSketchInfo(SN, SV);
68+
present(CHILD_ID, S_INFO, "TextSensor1");
69+
}
70+
71+
void loop() {
72+
if (!initialValueSent) {
73+
Serial.println("Sending initial value");
74+
// Send initial values.
75+
send(textMsg.set("-"));
76+
Serial.println("Requesting initial value from controller");
77+
request(CHILD_ID, V_TEXT);
78+
wait(2000, C_SET, V_TEXT);
79+
}
80+
}
81+
82+
void receive(const MyMessage &message) {
83+
if (message.type == V_TEXT) {
84+
if (!initialValueSent) {
85+
Serial.println("Receiving initial value from controller");
86+
initialValueSent = true;
87+
}
88+
// Dummy print
89+
Serial.print("Message: ");
90+
Serial.print(message.sensor);
91+
Serial.print(", Message: ");
92+
Serial.println(message.getString());
93+
// Send message to controller
94+
send(textMsg.set(message.getString()));
95+
}
96+
}
97+
```
98+
99+
[main component]: /components/mysensors/
100+
[api]: http://www.mysensors.org/download/

0 commit comments

Comments
 (0)