Skip to content

Commit 36698f1

Browse files
Add mysensors device tracker (home-assistant#1986)
* Add mysensors device tracker * Add release info
1 parent e8a25e8 commit 36698f1

6 files changed

+111
-4
lines changed

source/_components/binary_sensor.mysensors.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,4 @@ void loop()
8686
```
8787
8888
[main component]: /components/mysensors/
89-
[serial api]: https://www.mysensors.org/download/serial_api_15
89+
[serial api]: http://www.mysensors.org/download

source/_components/climate.mysensors.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,4 @@ void incomingMessage(const MyMessage &message) {
116116
```
117117
118118
[main component]: /components/mysensors/
119-
[serial api]: https://www.mysensors.org/download/serial_api_15
119+
[serial api]: http://www.mysensors.org/download
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
layout: page
3+
title: "MySensors Device Tracker"
4+
description: "Instructions how to use MySensors to track devices in Home Assistant."
5+
date: 2017-02-06 15:00 +0100
6+
sidebar: true
7+
comments: false
8+
sharing: true
9+
footer: true
10+
logo: mysensors.png
11+
ha_category: Presence Detection
12+
featured: false
13+
ha_release: "0.38"
14+
ha_iot_class: "Local Push"
15+
---
16+
17+
Integrates MySensors device trackers into Home Assistant. See the [main component] for configuration instructions.
18+
19+
The following sensor types are supported:
20+
21+
##### MySensors version 2.0 and higher
22+
23+
S_TYPE | V_TYPE
24+
-------------------|---------------------------------------
25+
S_GPS | V_POSITION
26+
27+
For more information, visit the [serial api] of MySensors.
28+
29+
### {% linkable_title MySensors 2.x example sketch %}
30+
31+
```cpp
32+
/**
33+
* Documentation: http://www.mysensors.org
34+
* Support Forum: http://forum.mysensors.org
35+
*
36+
* http://www.mysensors.org/build/gps
37+
*/
38+
39+
// Enable debug prints to serial monitor
40+
#define MY_DEBUG
41+
// Enable and select radio type attached
42+
#define MY_RADIO_NRF24
43+
//#define MY_RADIO_RFM69
44+
45+
#include <MySensors.h>
46+
47+
#define SN "GPS Sensor"
48+
#define SV "1.0"
49+
50+
// GPS position send interval (in millisectonds)
51+
#define GPS_SEND_INTERVAL 30000
52+
// The child id used for the gps sensor
53+
#define CHILD_ID_GPS 1
54+
55+
MyMessage msg(CHILD_ID_GPS, V_POSITION);
56+
57+
// Last time GPS position was sent to controller
58+
unsigned long lastGPSSent = -31000;
59+
60+
// Some buffers
61+
char latBuf[11];
62+
char lngBuf[11];
63+
char altBuf[6];
64+
char payload[30];
65+
66+
// Dummy values. Implementation of real GPS device is not done.
67+
float gpsLocationLat = 40.741895;
68+
float gpsLocationLng = -73.989308;
69+
float gpsAltitudeMeters = 12.0;
70+
71+
void setup() {
72+
73+
}
74+
75+
void presentation() {
76+
sendSketchInfo(SN, SV);
77+
present(CHILD_ID_GPS, S_GPS);
78+
}
79+
80+
void loop()
81+
{
82+
unsigned long currentTime = millis();
83+
84+
// Evaluate if it is time to send a new position
85+
bool timeToSend = currentTime - lastGPSSent > GPS_SEND_INTERVAL;
86+
87+
if (timeToSend) {
88+
// Send current gps location
89+
// Build position and altitude string to send
90+
dtostrf(gpsLocationLat, 1, 6, latBuf);
91+
dtostrf(gpsLocationLng, 1, 6, lngBuf);
92+
dtostrf(gpsAltitudeMeters, 1, 0, altBuf);
93+
sprintf(payload, "%s,%s,%s", latBuf, lngBuf, altBuf);
94+
95+
Serial.print(F("Position: "));
96+
Serial.println(payload);
97+
98+
send(msg.set(payload));
99+
lastGPSSent = currentTime;
100+
}
101+
}
102+
```
103+
104+
[main component]: /components/mysensors/
105+
[serial api]: http://www.mysensors.org/download

source/_components/light.mysensors.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ void incomingMessage(const MyMessage &message) {
111111
}
112112
}
113113
```
114+
114115
### {% linkable_title MySensors 2.x example sketch %}
115116
116117
```cpp
@@ -244,5 +245,6 @@ void send_status_message()
244245
}
245246
}
246247
```
248+
247249
[main component]: /components/mysensors/
248250
[serial api]: http://www.mysensors.org/download

source/_components/sensor.mysensors.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,4 @@ void receive(const MyMessage &message) {
181181
```
182182

183183
[main component]: /components/mysensors/
184-
[serial api]: https://www.mysensors.org/download/serial_api_15
184+
[serial api]: http://www.mysensors.org/download

source/_components/switch.mysensors.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,4 @@ void incomingMessage(const MyMessage &message) {
203203
```
204204
205205
[main component]: /components/mysensors/
206-
[serial api]: https://www.mysensors.org/download/serial_api_15
206+
[serial api]: http://www.mysensors.org/download

0 commit comments

Comments
 (0)