MySensors Library & Examples  2.3.2-38-gaa76d26
MockMySensors.ino
1 /*
2  * The MySensors Arduino library handles the wireless radio link and protocol
3  * between your home built sensors/actuators and HA controller of choice.
4  * The sensors forms a self healing radio network with optional repeaters. Each
5  * repeater and gateway builds a routing tables in EEPROM which keeps track of the
6  * network topology allowing messages to be routed to nodes.
7  *
8  * Created by Henrik Ekblad <[email protected]>
9  * Copyright (C) 2013-2020 Sensnology AB
10  * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
11  *
12  * Documentation: http://www.mysensors.org
13  * Support Forum: http://forum.mysensors.org
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * version 2 as published by the Free Software Foundation.
18  *
19  *******************************
20  *
21  * REVISION HISTORY
22  * Version 1.0 - Barduino 2015, GizMoCuz 2015
23  *
24  * DESCRIPTION
25  * This sketch is intended to create fake sensors which register and respond to the controller
26  *
27  */
28 
29 // Enable debug prints to serial monitor
30 #define MY_DEBUG
31 
32 // Enable and select radio type attached
33 #define MY_RADIO_RF24
34 //#define MY_RADIO_NRF5_ESB
35 //#define MY_RADIO_RFM69
36 //#define MY_RADIO_RFM95
37 //#define MY_PJON
38 
39 #define MY_NODE_ID 254
40 
41 #include <MySensors.h>
42 
43 #define RADIO_ERROR_LED_PIN 4 // Error led pin
44 #define RADIO_RX_LED_PIN 6 // Receive led pin
45 #define RADIO_TX_LED_PIN 5 // the PCB, on board LED
46 
47 // Wait times
48 #define LONG_WAIT 500
49 #define SHORT_WAIT 50
50 
51 #define SKETCH_NAME "MockMySensors "
52 #define SKETCH_VERSION "v0.5"
53 
54 // Define Sensors ids
55 /* S_DOOR, S_MOTION, S_SMOKE, S_LIGHT, S_DIMMER, S_COVER, S_TEMP, S_HUM, S_BARO, S_WIND,
56  S_RAIN, S_UV, S_WEIGHT, S_POWER, S_HEATER, S_DISTANCE, S_LIGHT_LEVEL, S_ARDUINO_NODE,
57  S_ARDUINO_REPEATER_NODE, S_LOCK, S_IR, S_WATER, S_AIR_QUALITY, S_CUSTOM, S_DUST,
58  S_SCENE_CONTROLLER
59 */
60 
63 
64 
65 // Some of these ID's have not been updated for v1.5. Uncommenting too many of them
66 // will make the sketch too large for a pro mini's memory so it's probably best to try
67 // one at a time.
68 
69 #define ID_S_ARMED 0 // dummy to control armed stated for several sensors
70 #define ID_S_DOOR 1
71 //#define ID_S_MOTION 2
72 //#define ID_S_SMOKE 3
73 //#define ID_S_LIGHT 4
74 //#define ID_S_DIMMER 5
75 //#define ID_S_COVER 6
76 //#define ID_S_TEMP 7
77 //#define ID_S_HUM 8
78 //#define ID_S_BARO 9
79 //#define ID_S_WIND 10
80 //#define ID_S_RAIN 11
81 //#define ID_S_UV 12
82 //#define ID_S_WEIGHT 13
83 //#define ID_S_POWER 14
84 //#define ID_S_HEATER 15
85 //#define ID_S_DISTANCE 16
86 //#define ID_S_LIGHT_LEVEL 17
87 //#define ID_S_LOCK 18
88 //#define ID_S_IR 19
89 //#define ID_S_WATER 20
90 //#define ID_S_AIR_QUALITY 21
91 //#define ID_S_DUST 22
92 //#define ID_S_SCENE_CONTROLLER 23
94 //#define ID_S_RGB_LIGHT 24
95 //#define ID_S_RGBW_LIGHT 25
96 //#define ID_S_COLOR_SENSOR 26
97 //#define ID_S_HVAC 27
98 //#define ID_S_MULTIMETER 28
99 //#define ID_S_SPRINKLER 29
100 //#define ID_S_WATER_LEAK 30
101 //#define ID_S_SOUND 31
102 //#define ID_S_VIBRATION 32
103 //#define ID_S_MOISTURE 33
104 //
105 //#define ID_S_CUSTOM 99
106 
107 
108 
109 // Global Vars
110 uint32_t SLEEP_TIME = 900000; // Sleep time between reads (in milliseconds)
111 bool metric = true;
112 long randNumber;
113 
114 
115 //Instantiate Messages objects
116 
117 #ifdef ID_S_ARMED
118 bool isArmed;
119 #endif
120 
121 #ifdef ID_S_DOOR // V_TRIPPED, V_ARMED
122 MyMessage msg_S_DOOR_T(ID_S_DOOR,V_TRIPPED);
123 MyMessage msg_S_DOOR_A(ID_S_DOOR,V_ARMED);
124 #endif
125 
126 #ifdef ID_S_MOTION // V_TRIPPED, V_ARMED
127 MyMessage msg_S_MOTION_A(ID_S_MOTION,V_ARMED);
128 MyMessage msg_S_MOTION_T(ID_S_MOTION,V_TRIPPED);
129 #endif
130 
131 #ifdef ID_S_SMOKE // V_TRIPPED, V_ARMED
132 MyMessage msg_S_SMOKE_T(ID_S_SMOKE,V_TRIPPED);
133 MyMessage msg_S_SMOKE_A(ID_S_SMOKE,V_ARMED);
134 #endif
135 
136 #ifdef ID_S_LIGHT
137 MyMessage msg_S_LIGHT(ID_S_LIGHT,V_LIGHT);
138 bool isLightOn=0;
139 #endif
140 
141 #ifdef ID_S_DIMMER
142 MyMessage msg_S_DIMMER(ID_S_DIMMER,V_DIMMER);
143 int dimmerVal=100;
144 #endif
145 
146 #ifdef ID_S_COVER
147 MyMessage msg_S_COVER_U(ID_S_COVER,V_UP);
148 MyMessage msg_S_COVER_D(ID_S_COVER,V_DOWN);
149 MyMessage msg_S_COVER_S(ID_S_COVER,V_STOP);
150 MyMessage msg_S_COVER_V(ID_S_COVER,V_VAR1);
151 int coverState=0; //0=Stop; 1=up; -1=down
152 #endif
153 
154 #ifdef ID_S_TEMP
155 MyMessage msg_S_TEMP(ID_S_TEMP,V_TEMP);
156 #endif
157 
158 #ifdef ID_S_HUM
159 MyMessage msg_S_HUM(ID_S_HUM,V_HUM);
160 #endif
161 
162 #ifdef ID_S_BARO
163 MyMessage msg_S_BARO_P(ID_S_BARO,V_PRESSURE);
164 MyMessage msg_S_BARO_F(ID_S_BARO,V_FORECAST);
165 #endif
166 
167 #ifdef ID_S_WIND
168 MyMessage msg_S_WIND_S(ID_S_WIND,V_WIND);
169 MyMessage msg_S_WIND_G(ID_S_WIND,V_GUST);
170 MyMessage msg_S_WIND_D(ID_S_WIND,V_DIRECTION);
171 #endif
172 
173 #ifdef ID_S_RAIN
174 MyMessage msg_S_RAIN_A(ID_S_RAIN,V_RAIN);
175 MyMessage msg_S_RAIN_R(ID_S_RAIN,V_RAINRATE);
176 #endif
177 
178 #ifdef ID_S_UV
179 MyMessage msg_S_UV(ID_S_UV,V_UV);
180 #endif
181 
182 #ifdef ID_S_WEIGHT
183 MyMessage msg_S_WEIGHT(ID_S_WEIGHT,V_WEIGHT);
184 #endif
185 
186 #ifdef ID_S_POWER
187 MyMessage msg_S_POWER_W(ID_S_POWER,V_WATT);
188 MyMessage msg_S_POWER_K(ID_S_POWER,V_KWH);
189 #endif
190 
191 
192 #ifdef ID_S_HEATER
193 
195 
196 MyMessage msg_S_HEATER_SET_POINT(ID_S_HEATER,
197  V_HVAC_SETPOINT_HEAT); // HVAC/Heater setpoint (Integer between 0-100). S_HEATER, S_HVAC
198 MyMessage msg_S_HEATER_FLOW_STATE(ID_S_HEATER,
199  V_HVAC_FLOW_STATE); // Mode of header. One of "Off", "HeatOn", "CoolOn", or "AutoChangeOver" // S_HVAC, S_HEATER
200 
201 //MyMessage msg_S_HEATER_STATUS(ID_S_HEATER,V_STATUS);
202 //MyMessage msg_S_HEATER_TEMP(ID_S_HEATER,V_TEMP);
203 
204 float heater_setpoint=21.5;
205 String heater_flow_state="Off";
206 
207 // float heater_temp=23.5;
208 // bool heater_status=false;
209 
210 
211 // V_TEMP // Temperature
212 // V_STATUS // Binary status. 0=off 1=on
213 // V_HVAC_FLOW_STATE // Mode of header. One of "Off", "HeatOn", "CoolOn", or "AutoChangeOver"
214 // V_HVAC_SPEED // HVAC/Heater fan speed ("Min", "Normal", "Max", "Auto")
215 // V_HVAC_SETPOINT_HEAT // HVAC/Heater setpoint
216 #endif
217 
218 #ifdef ID_S_DISTANCE
219 MyMessage msg_S_DISTANCE(ID_S_DISTANCE,V_DISTANCE);
220 #endif
221 
222 #ifdef ID_S_LIGHT_LEVEL
223 MyMessage msg_S_LIGHT_LEVEL(ID_S_LIGHT_LEVEL,V_LIGHT_LEVEL);
224 #endif
225 
226 #ifdef ID_S_LOCK
227 MyMessage msg_S_LOCK(ID_S_LOCK,V_LOCK_STATUS);
228 bool isLocked = 0;
229 #endif
230 
231 #ifdef ID_S_IR
232 MyMessage msg_S_IR_S(ID_S_IR,V_IR_SEND);
233 MyMessage msg_S_IR_R(ID_S_IR,V_IR_RECEIVE);
234 long irVal = 0;
235 #endif
236 
237 #ifdef ID_S_WATER
238 MyMessage msg_S_WATER_F(ID_S_WATER,V_FLOW);
239 MyMessage msg_S_WATER_V(ID_S_WATER,V_VOLUME);
240 #endif
241 
242 #ifdef ID_S_AIR_QUALITY
243 MyMessage msg_S_AIR_QUALITY(ID_S_AIR_QUALITY,V_LEVEL);
244 #endif
245 
246 #ifdef ID_S_DUST
247 MyMessage msg_S_DUST(ID_S_DUST,V_LEVEL);
248 #endif
249 
250 #ifdef ID_S_SCENE_CONTROLLER
251 MyMessage msg_S_SCENE_CONTROLLER_ON(ID_S_SCENE_CONTROLLER,V_SCENE_ON);
252 MyMessage msg_S_SCENE_CONTROLLER_OF(ID_S_SCENE_CONTROLLER,V_SCENE_OFF);
253 // not sure if scene controller sends int or chars
254 // betting on ints as Touch Display Scen by Hek // compiler warnings
255 char *scenes[] = {
256  (char *)"Good Morning",
257  (char *)"Clean Up!",
258  (char *)"All Lights Off",
259  (char *)"Music On/Off"
260 };
261 
262 int sceneVal=0;
263 int sceneValPrevious=0;
264 
265 #endif
266 
267 #ifdef ID_S_RGB_LIGHT
268 MyMessage msg_S_RGB_LIGHT_V_RGB(ID_S_RGB_LIGHT,V_RGB);
269 MyMessage msg_S_RGB_LIGHT_V_WATT(ID_S_RGB_LIGHT,V_WATT);
270 String rgbState="000000";
271 //RGB light V_RGB, V_WATT
272 //RGB value transmitted as ASCII hex string (I.e "ff0000" for red)
273 #endif
274 
275 #ifdef ID_S_RGBW_LIGHT
276 MyMessage msg_S_RGBW_LIGHT_V_RGBW(ID_S_RGBW_LIGHT,V_RGBW);
277 MyMessage msg_S_RGBW_LIGHT_V_WATT(ID_S_RGBW_LIGHT,V_WATT);
278 String rgbwState="00000000";
279 //RGBW light (with separate white component) V_RGBW, V_WATT
280 //RGBW value transmitted as ASCII hex string (I.e "ff0000ff" for red + full white) S_RGBW_LIGHT
281 #endif
282 
283 #ifdef ID_S_COLOR_SENSOR
284 MyMessage msg_S_COLOR_SENSOR_V_RGB(ID_S_COLOR_SENSOR,V_RGB);
285 //Color sensor V_RGB
286 //RGB value transmitted as ASCII hex string (I.e "ff0000" for red) S_RGB_LIGHT, S_COLOR_SENSOR
287 #endif
288 
289 #ifdef ID_S_HVAC
290 MyMessage msg_S_HVAC_V_HVAC_SETPOINT_HEAT(ID_S_HVAC,V_HVAC_SETPOINT_HEAT);
291 MyMessage msg_S_HVAC_V_HVAC_SETPOINT_COOL(ID_S_HVAC,V_HVAC_SETPOINT_COOL);
292 MyMessage msg_S_HVAC_V_HVAC_FLOW_STATET(ID_S_HVAC,V_HVAC_FLOW_STATE);
293 MyMessage msg_S_HVAC_V_HVAC_FLOW_MODE(ID_S_HVAC,V_HVAC_FLOW_MODE);
294 MyMessage msg_S_HVAC_V_HVAC_SPEED(ID_S_HVAC,V_HVAC_SPEED);
295 
296 float hvac_SetPointHeat = 16.5;
297 float hvac_SetPointCool = 25.5;
298 String hvac_FlowState = "AutoChangeOver";
299 String hvac_FlowMode = "Auto";
300 String hvac_Speed = "Normal";
301 
302 //Thermostat/HVAC device
303 //V_HVAC_SETPOINT_HEAT, // HVAC/Heater setpoint
304 //V_HVAC_SETPOINT_COOL, // HVAC cold setpoint
305 //V_HVAC_FLOW_STATE, // Mode of header. One of "Off", "HeatOn", "CoolOn", or "AutoChangeOver"
306 //V_HVAC_FLOW_MODE, // Flow mode for HVAC ("Auto", "ContinuousOn", "PeriodicOn")
307 //V_HVAC_SPEED // HVAC/Heater fan speed ("Min", "Normal", "Max", "Auto")
308 
309 // NOT IMPLEMENTED YET
310 //V_TEMP // Temperature
311 //V_STATUS // Binary status. 0=off 1=on
312 #endif
313 
314 #ifdef ID_S_MULTIMETER
315 MyMessage msg_S_MULTIMETER_V_IMPEDANCE(ID_S_MULTIMETER,V_IMPEDANCE);
316 MyMessage msg_S_MULTIMETER_V_VOLTAGE(ID_S_MULTIMETER,V_VOLTAGE);
317 MyMessage msg_S_MULTIMETER_V_CURRENT(ID_S_MULTIMETER,V_CURRENT);
318 
319 // Multimeter device V_VOLTAGE, V_CURRENT, V_IMPEDANCE
320 // V_IMPEDANCE 14 Impedance value
321 // V_VOLTAGE 38 Voltage level
322 // V_CURRENT 39 Current level
323 #endif
324 
325 #ifdef ID_S_SPRINKLER
326 // S_SPRINKLER 31 Sprinkler device V_STATUS (turn on/off), V_TRIPPED (if fire detecting device)
327 // V_STATUS 2 Binary status. 0=off 1=on
328 // V_ARMED 15 Armed status of a security sensor. 1=Armed, 0=Bypassed
329 // V_TRIPPED 16 Tripped status of a security sensor. 1=Tripped, 0=Untripped
330 #endif
331 
332 #ifdef ID_S_WATER_LEAK
333 #endif
334 #ifdef ID_S_SOUND
335 #endif
336 #ifdef ID_S_VIBRATION
337 #endif
338 #ifdef ID_S_MOISTURE
339 #endif
340 
341 #ifdef ID_S_MOISTURE
342 MyMessage msg_S_MOISTURE(ID_S_MOISTURE,V_LEVEL);
343 #endif
344 
345 #ifdef ID_S_CUSTOM
346 MyMessage msg_S_CUSTOM_1(ID_S_CUSTOM,V_VAR1);
347 MyMessage msg_S_CUSTOM_2(ID_S_CUSTOM,V_VAR2);
348 MyMessage msg_S_CUSTOM_3(ID_S_CUSTOM,V_VAR3);
349 MyMessage msg_S_CUSTOM_4(ID_S_CUSTOM,V_VAR4);
350 MyMessage msg_S_CUSTOM_5(ID_S_CUSTOM,V_VAR5);
351 #endif
352 
353 
354 
355 
356 void setup()
357 {
358  // Random SEED
359  randomSeed(analogRead(0));
360 
361  wait(LONG_WAIT);
362  Serial.println("GW Started");
363 }
364 
366 {
367  // Send the Sketch Version Information to the Gateway
368  Serial.print("Send Sketch Info: ");
369  sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
370  Serial.print(SKETCH_NAME);
371  Serial.println(SKETCH_VERSION);
372  wait(LONG_WAIT);
373 
374  // Get controller configuration
375  Serial.print("Get Config: ");
376  metric = getControllerConfig().isMetric;
377  Serial.println(metric ? "Metric":"Imperial");
378  wait(LONG_WAIT);
379 
380  // Init Armed
381 #ifdef ID_S_ARMED
382  isArmed = true;
383 #endif
384 
385  // Register all sensors to gw (they will be created as child devices)
386  Serial.println("Presenting Nodes");
387  Serial.println("________________");
388 
389 #ifdef ID_S_DOOR
390  Serial.println(" S_DOOR");
391  present(ID_S_DOOR,S_DOOR,"Outside Door");
392  wait(SHORT_WAIT);
393 #endif
394 
395 #ifdef ID_S_MOTION
396  Serial.println(" S_MOTION");
397  present(ID_S_MOTION,S_MOTION,"Outside Motion");
398  wait(SHORT_WAIT);
399 #endif
400 
401 #ifdef ID_S_SMOKE
402  Serial.println(" S_SMOKE");
403  present(ID_S_SMOKE,S_SMOKE,"Kitchen Smoke");
404  wait(SHORT_WAIT);
405 #endif
406 
407 #ifdef ID_S_LIGHT
408  Serial.println(" S_LIGHT");
409  present(ID_S_LIGHT,S_LIGHT,"Hall Light");
410  wait(SHORT_WAIT);
411 #endif
412 
413 #ifdef ID_S_DIMMER
414  Serial.println(" S_DIMMER");
415  present(ID_S_DIMMER,S_DIMMER,"Living room dimmer");
416  wait(SHORT_WAIT);
417 #endif
418 
419 #ifdef ID_S_COVER
420  Serial.println(" S_COVER");
421  present(ID_S_COVER,S_COVER,"Window cover");
422  wait(SHORT_WAIT);
423 #endif
424 
425 #ifdef ID_S_TEMP
426  Serial.println(" S_TEMP");
427  present(ID_S_TEMP,S_TEMP,"House Temperarue");
428  wait(SHORT_WAIT);
429 #endif
430 
431 #ifdef ID_S_HUM
432  Serial.println(" S_HUM");
433  present(ID_S_HUM,S_HUM,"Current Humidity");
434  wait(SHORT_WAIT);
435 #endif
436 
437 #ifdef ID_S_BARO
438  Serial.println(" S_BARO");
439  present(ID_S_BARO,S_BARO," Air pressure");
440  wait(SHORT_WAIT);
441 #endif
442 
443 #ifdef ID_S_WIND
444  Serial.println(" S_WIND");
445  present(ID_S_WIND,S_WIND,"Wind Station");
446  wait(SHORT_WAIT);
447 #endif
448 
449 #ifdef ID_S_RAIN
450  Serial.println(" S_RAIN");
451  present(ID_S_RAIN,S_RAIN,"Rain Station");
452  wait(SHORT_WAIT);
453 #endif
454 
455 #ifdef ID_S_UV
456  Serial.println(" S_UV");
457  present(ID_S_UV,S_UV,"Ultra Violet");
458  wait(SHORT_WAIT);
459 #endif
460 
461 #ifdef ID_S_WEIGHT
462  Serial.println(" S_WEIGHT");
463  present(ID_S_WEIGHT,S_WEIGHT,"Outdoor Scale");
464  wait(SHORT_WAIT);
465 #endif
466 
467 #ifdef ID_S_POWER
468  Serial.println(" S_POWER");
469  present(ID_S_POWER,S_POWER,"Power Metric");
470  wait(SHORT_WAIT);
471 #endif
472 
473 #ifdef ID_S_HEATER
474  Serial.println(" S_HEATER");
475  present(ID_S_HEATER,S_HEATER,"Garage Heater");
476  wait(SHORT_WAIT);
477 #endif
478 
479 #ifdef ID_S_DISTANCE
480  Serial.println(" S_DISTANCE");
481  present(ID_S_DISTANCE,S_DISTANCE,"Distance Measure");
482  wait(SHORT_WAIT);
483 #endif
484 
485 #ifdef ID_S_LIGHT_LEVEL
486  Serial.println(" S_LIGHT_LEVEL");
487  present(ID_S_LIGHT_LEVEL,S_LIGHT_LEVEL,"Outside Light Level");
488  wait(SHORT_WAIT);
489 #endif
490 
491 #ifdef ID_S_LOCK
492  Serial.println(" S_LOCK");
493  present(ID_S_LOCK,S_LOCK,"Front Door Lock");
494  wait(SHORT_WAIT);
495 #endif
496 
497 #ifdef ID_S_IR
498  Serial.println(" S_IR");
499  present(ID_S_IR,S_IR,"Univeral Command");
500  wait(SHORT_WAIT);
501 #endif
502 
503 #ifdef ID_S_WATER
504  Serial.println(" S_WATER");
505  present(ID_S_WATER,S_WATER,"Water Level");
506  wait(SHORT_WAIT);
507 #endif
508 
509 #ifdef ID_S_AIR_QUALITY
510  Serial.println(" S_AIR_QUALITY");
511  present(ID_S_AIR_QUALITY,S_AIR_QUALITY,"Air Station");
512  wait(SHORT_WAIT);
513 #endif
514 
515 #ifdef ID_S_DUST
516  Serial.println(" S_DUST");
517  present(ID_S_DUST,S_DUST,"Dust Level");
518  wait(SHORT_WAIT);
519 #endif
520 
521 #ifdef ID_S_SCENE_CONTROLLER
522  Serial.println(" S_SCENE_CONTROLLER");
523  present(ID_S_SCENE_CONTROLLER,S_SCENE_CONTROLLER,"Scene Controller");
524  wait(SHORT_WAIT);
525 #endif
526 
527 #ifdef ID_S_RGB_LIGHT
528  Serial.println(" RGB_LIGHT");
529  present(ID_S_RGB_LIGHT,S_RGB_LIGHT,"Mood Light");
530  wait(SHORT_WAIT);
531 #endif
532 
533 #ifdef ID_S_RGBW_LIGHT
534  Serial.println(" RGBW_LIGHT");
535  present(ID_S_RGBW_LIGHT,S_RGBW_LIGHT,"Mood Light 2");
536  wait(SHORT_WAIT);
537 #endif
538 
539 #ifdef ID_S_COLOR_SENSOR
540  Serial.println(" COLOR_SENSOR");
541  present(ID_S_COLOR_SENSOR,S_COLOR_SENSOR,"Hall Painting");
542  wait(SHORT_WAIT);
543 #endif
544 
545 #ifdef ID_S_HVAC
546  Serial.println(" HVAC");
547  present(ID_S_HVAC,S_HVAC,"HVAC");
548  wait(SHORT_WAIT);
549 #endif
550 
551 #ifdef ID_S_MULTIMETER
552  Serial.println(" MULTIMETER");
553  present(ID_S_MULTIMETER,S_MULTIMETER,"Electric Staion");
554  wait(SHORT_WAIT);
555 #endif
556 
557 #ifdef ID_S_SPRINKLER
558 #endif
559 #ifdef ID_S_WATER_LEAK
560 #endif
561 #ifdef ID_S_SOUND
562 #endif
563 #ifdef ID_S_VIBRATION
564 #endif
565 #ifdef ID_S_MOISTURE
566 #endif
567 
568 #ifdef ID_S_MOISTURE
569  Serial.println(" S_MOISTURE");
570  present(ID_S_MOISTURE,S_MOISTURE,"Basement Sensor");
571  wait(SHORT_WAIT);
572 #endif
573 
574 #ifdef ID_S_CUSTOM
575  Serial.println(" S_CUSTOM");
576  present(ID_S_CUSTOM,S_CUSTOM,"Other Stuff");
577  wait(SHORT_WAIT);
578 #endif
579 
580 
581 
582  Serial.println("________________");
583 
584 }
585 
586 void loop()
587 {
588  Serial.println("");
589  Serial.println("");
590  Serial.println("");
591  Serial.println("#########################");
592  randNumber=random(0,101);
593 
594  Serial.print("RandomNumber:");
595  Serial.println(randNumber);
596  // Send fake battery level
597  Serial.println("Send Battery Level");
598  sendBatteryLevel(randNumber);
599  wait(LONG_WAIT);
600 
601  // Request time
602  Serial.println("Request Time");
603  requestTime();
604  wait(LONG_WAIT);
605 
606  //Read Sensors
607 #ifdef ID_S_DOOR
608  door();
609 #endif
610 
611 #ifdef ID_S_MOTION
612  motion();
613 #endif
614 
615 #ifdef ID_S_SMOKE
616  smoke();
617 #endif
618 
619 #ifdef ID_S_LIGHT
620  light();
621 #endif
622 
623 #ifdef ID_S_DIMMER
624  dimmer();
625 #endif
626 
627 #ifdef ID_S_COVER
628  cover();
629 #endif
630 
631 #ifdef ID_S_TEMP
632  temp();
633 #endif
634 
635 #ifdef ID_S_HUM
636  hum();
637 #endif
638 
639 #ifdef ID_S_BARO
640  baro();
641 #endif
642 
643 #ifdef ID_S_WIND
644  wind();
645 #endif
646 
647 #ifdef ID_S_RAIN
648  rain();
649 #endif
650 
651 #ifdef ID_S_UV
652  uv();
653 #endif
654 
655 #ifdef ID_S_WEIGHT
656  weight();
657 #endif
658 
659 #ifdef ID_S_POWER
660  power();
661 #endif
662 
663 #ifdef ID_S_HEATER
664  heater();
665 #endif
666 
667 #ifdef ID_S_DISTANCE
668  distance();
669 #endif
670 
671 #ifdef ID_S_LIGHT_LEVEL
672  light_level();
673 #endif
674 
675 #ifdef ID_S_LOCK
676  lock();
677 #endif
678 
679 #ifdef ID_S_IR
680  ir();
681 #endif
682 
683 #ifdef ID_S_WATER
684  water();
685 #endif
686 
687 #ifdef ID_S_AIR_QUALITY
688  air();
689 #endif
690 
691 #ifdef ID_S_DUST
692  dust();
693 #endif
694 
695 #ifdef ID_S_SCENE_CONTROLLER
696  scene();
697 #endif
698 
699 #ifdef ID_S_RGB_LIGHT
700  rgbLight();
701 #endif
702 
703 #ifdef ID_S_RGBW_LIGHT
704  rgbwLight();
705 #endif
706 
707 #ifdef ID_S_COLOR_SENSOR
708  color();
709 #endif
710 
711 #ifdef ID_S_HVAC
712  hvac();
713 #endif
714 
715 #ifdef ID_S_MULTIMETER
716  multimeter();
717 #endif
718 
719 #ifdef ID_S_SPRINKLER
720 #endif
721 #ifdef ID_S_WATER_LEAK
722 #endif
723 #ifdef ID_S_SOUND
724 #endif
725 #ifdef ID_S_VIBRATION
726 #endif
727 #ifdef ID_S_MOISTURE
728 #endif
729 
730 #ifdef ID_S_MOISTURE
731  moisture();
732 #endif
733 
734 #ifdef ID_S_CUSTOM
735  custom();
736 #endif
737 
738  sendBatteryLevel(randNumber);
739  wait(SHORT_WAIT);
740  Serial.println("#########################");
741  wait(SLEEP_TIME); //sleep a bit
742 }
743 
744 // This is called when a new time value was received
745 void receiveTime(uint32_t controllerTime)
746 {
747 
748  Serial.print("Time value received: ");
749  Serial.println(controllerTime);
750 
751 }
752 
753 //void door(){}
754 
755 #ifdef ID_S_DOOR
756 void door()
757 {
758 
759  Serial.print("Door is: " );
760 
761  if (randNumber <= 50) {
762  Serial.println("Open");
763  send(msg_S_DOOR_T.set((int16_t)1));
764  } else {
765  Serial.println("Closed");
766  send(msg_S_DOOR_T.set((int16_t)0));
767  }
768 #ifdef ID_S_ARMED
769  Serial.print("System is: " );
770  Serial.println((isArmed ? "Armed":"Disarmed"));
771  send(msg_S_DOOR_A.set(isArmed));
772 #endif
773 }
774 #endif
775 
776 #ifdef ID_S_MOTION
777 void motion()
778 {
779 
780  Serial.print("Motion is: " );
781 
782  if (randNumber <= 50) {
783  Serial.println("Active");
784  send(msg_S_MOTION_T.set(1));
785  } else {
786  Serial.println("Quiet");
787  send(msg_S_MOTION_T.set(0));
788  }
789 
790 #ifdef ID_S_ARMED
791  Serial.print("System is: " );
792  Serial.println((isArmed ? "Armed":"Disarmed"));
793  send(msg_S_MOTION_A.set(isArmed));
794 #endif
795 }
796 #endif
797 
798 #ifdef ID_S_SMOKE
799 void smoke()
800 {
801 
802  Serial.print("Smoke is: " );
803 
804  if (randNumber <= 50) {
805  Serial.println("Active");
806  send(msg_S_SMOKE_T.set(1));
807  } else {
808  Serial.println("Quiet");
809  send(msg_S_SMOKE_T.set(0));
810  }
811 
812 #ifdef ID_S_ARMED
813  Serial.print("System is: " );
814  Serial.println((isArmed ? "Armed":"Disarmed"));
815  send(msg_S_SMOKE_A.set(isArmed));
816 #endif
817 
818 }
819 #endif
820 
821 #ifdef ID_S_LIGHT
822 void light()
823 {
824 
825  Serial.print("Light is: " );
826  Serial.println((isLightOn ? "On":"Off"));
827 
828  send(msg_S_LIGHT.set(isLightOn));
829 
830 }
831 #endif
832 
833 #ifdef ID_S_DIMMER
834 void dimmer()
835 {
836 
837  Serial.print("Dimmer is set to: " );
838  Serial.println(dimmerVal);
839 
840  send(msg_S_DIMMER.set(dimmerVal));
841 
842 }
843 #endif
844 
845 #ifdef ID_S_COVER
846 void cover()
847 {
848 
849  Serial.print("Cover is : " );
850 
851  if (coverState == 1) {
852  Serial.println("Opening");
853  send(msg_S_COVER_U.set(1));
854  } else if (coverState == -1) {
855  Serial.println("Closing");
856  send(msg_S_COVER_D.set(0));
857  } else {
858  Serial.println("Idle");
859  send(msg_S_COVER_S.set(-1));
860  }
861  send(msg_S_COVER_V.set(coverState));
862 }
863 #endif
864 
865 #ifdef ID_S_TEMP
866 void temp()
867 {
868 
869  Serial.print("Temperature is: " );
870  Serial.println(map(randNumber,1,100,0,45));
871 
872  send(msg_S_TEMP.set(map(randNumber,1,100,0,45)));
873 
874 }
875 #endif
876 
877 #ifdef ID_S_HUM
878 void hum()
879 {
880 
881  Serial.print("Humidity is: " );
882  Serial.println(randNumber);
883 
884  send(msg_S_HUM.set(randNumber));
885 
886 }
887 #endif
888 
889 #ifdef ID_S_BARO
890 void baro()
891 {
892 
893  const char *weather[] = {"stable","sunny","cloudy","unstable","thunderstorm","unknown"};
894  long pressure = map(randNumber,1,100,870,1086);// hPa?
895  int forecast = map(randNumber,1,100,0,5);
896 
897  Serial.print("Atmospheric Pressure is: " );
898  Serial.println(pressure);
899  send(msg_S_BARO_P.set(pressure));
900 
901  Serial.print("Weather forecast: " );
902  Serial.println(weather[forecast]);
903  send(msg_S_BARO_F.set(weather[forecast]));
904 
905 }
906 #endif
907 
908 #ifdef ID_S_WIND
909 void wind()
910 {
911 
912  Serial.print("Wind Speed is: " );
913  Serial.println(randNumber);
914  send(msg_S_WIND_S.set(randNumber));
915 
916  Serial.print("Wind Gust is: " );
917  Serial.println(randNumber+10);
918  send(msg_S_WIND_G.set(randNumber+10));
919 
920  Serial.print("Wind Direction is: " );
921  Serial.println(map(randNumber,1,100,0,360));
922  send(msg_S_WIND_D.set(map(randNumber,1,100,0,360)));
923 
924 }
925 #endif
926 
927 #ifdef ID_S_RAIN
928 void rain()
929 {
930 
931  Serial.print("Rain amount is: " );
932  Serial.println(randNumber);
933 
934  send(msg_S_RAIN_A.set(randNumber));
935 
936  Serial.print("Rain rate is: " );
937  Serial.println(randNumber/60);
938 
939  send(msg_S_RAIN_R.set(randNumber/60,1));
940 
941 }
942 #endif
943 
944 #ifdef ID_S_UV
945 void uv()
946 {
947 
948  Serial.print("Ultra Violet level is: " );
949  Serial.println(map(randNumber,1,100,0,15));
950 
951  send(msg_S_UV.set(map(randNumber,1,100,0,15)));
952 
953 }
954 #endif
955 
956 #ifdef ID_S_WEIGHT
957 void weight()
958 {
959 
960  Serial.print("Weight is: " );
961  Serial.println(map(randNumber,1,100,0,150));
962 
963  send(msg_S_WEIGHT.set(map(randNumber,1,100,0,150)));
964 
965 }
966 #endif
967 
968 #ifdef ID_S_POWER
969 void power()
970 {
971 
972  Serial.print("Watt is: " );
973  Serial.println(map(randNumber,1,100,0,150));
974  send(msg_S_POWER_W.set(map(randNumber,1,100,0,150)));
975 
976  Serial.print("KWH is: " );
977  Serial.println(map(randNumber,1,100,0,150));
978  send(msg_S_POWER_K.set(map(randNumber,1,100,0,150)));
979 
980 }
981 #endif
982 
983 #ifdef ID_S_HEATER
984 void heater()
985 {
986  // float heater_setpoint=21.5;
987  // float heater_temp=23.5;
988  // bool heater_status=false;
989  // String heatState="Off";
990 
991  Serial.print("Heater flow state is: " );
992  Serial.println(heater_flow_state);
993  send(msg_S_HEATER_FLOW_STATE.set(heater_flow_state.c_str()));
994 
995  // Serial.print("Heater on/off is: " );
996  // Serial.println((heater_status==true)?"On":"Off");
997  // send(msg_S_HEATER_STATUS.set(heater_status));
998 
999  // Serial.print("Heater Temperature is: " );
1000  // Serial.println(heater_temp,1);
1001  // send(msg_S_HEATER_TEMP.set(heater_temp,1));
1002 
1003  Serial.print("Heater Setpoint: " );
1004  Serial.println(heater_setpoint,1);
1005  send(msg_S_HEATER_SET_POINT.set(heater_setpoint,1));
1006 }
1007 #endif
1008 
1009 #ifdef ID_S_DISTANCE
1010 void distance()
1011 {
1012 
1013  Serial.print("Distance is: " );
1014  Serial.println(map(randNumber,1,100,0,150));
1015 
1016  send(msg_S_DISTANCE.set(map(randNumber,1,100,0,150)));
1017 
1018 }
1019 #endif
1020 
1021 #ifdef ID_S_LIGHT_LEVEL
1022 void light_level()
1023 {
1024 
1025  Serial.print("Light is: " );
1026  Serial.println(map(randNumber,1,100,0,150));
1027 
1028  send(msg_S_LIGHT_LEVEL.set(map(randNumber,1,100,0,150)));
1029 
1030 }
1031 #endif
1032 
1033 #ifdef ID_S_LOCK
1034 void lock()
1035 {
1036 
1037  Serial.print("Lock is: " );
1038  Serial.println((isLocked ? "Locked":"Unlocked"));
1039  send(msg_S_LOCK.set(isLocked));
1040 
1041 }
1042 #endif
1043 
1044 #ifdef ID_S_IR
1045 void ir()
1046 {
1047 
1048  Serial.print("Infrared is: " );
1049  Serial.println(irVal);
1050 
1051  send(msg_S_IR_S.set(irVal));
1052  send(msg_S_IR_R.set(irVal));
1053 
1054 }
1055 #endif
1056 
1057 #ifdef ID_S_WATER
1058 void water()
1059 {
1060 
1061  Serial.print("Water flow is: " );
1062  Serial.println(map(randNumber,1,100,0,150));
1063 
1064  send(msg_S_WATER_F.set(map(randNumber,1,100,0,150)));
1065 
1066  Serial.print("Water volume is: " );
1067  Serial.println(map(randNumber,1,100,0,150));
1068 
1069  send(msg_S_WATER_V.set(map(randNumber,1,100,0,150)));
1070 
1071 }
1072 #endif
1073 
1074 #ifdef ID_S_AIR_QUALITY
1075 void air()
1076 {
1077 
1078  Serial.print("Air Quality is: " );
1079  Serial.println(randNumber);
1080 
1081  send(msg_S_AIR_QUALITY.set(randNumber));
1082 
1083 }
1084 #endif
1085 
1086 #ifdef ID_S_DUST
1087 void dust()
1088 {
1089 
1090  Serial.print("Dust level is: " );
1091  Serial.println(randNumber);
1092 
1093  send(msg_S_DUST.set(randNumber));
1094 
1095 }
1096 #endif
1097 
1098 #ifdef ID_S_SCENE_CONTROLLER
1099 void scene()
1100 {
1101 
1102  Serial.print("Scene is: " );
1103  Serial.println(scenes[sceneVal]);
1104 
1105  if(sceneValPrevious != sceneVal) {
1106  send(msg_S_SCENE_CONTROLLER_OF.set(sceneValPrevious));
1107  send(msg_S_SCENE_CONTROLLER_ON.set(sceneVal));
1108  sceneValPrevious=sceneVal;
1109  }
1110 
1111 }
1112 #endif
1113 
1114 #ifdef ID_S_RGB_LIGHT
1115 void rgbLight()
1116 {
1117 
1118  Serial.print("RGB Light state is: " );
1119  Serial.println(rgbState);
1120  send(msg_S_RGB_LIGHT_V_RGB.set(rgbState.c_str()));
1121 
1122  Serial.print("RGB Light Watt is: " );
1123  Serial.println(map(randNumber,1,100,0,150));
1124  send(msg_S_RGB_LIGHT_V_WATT.set(map(randNumber,1,100,0,150)));
1125 
1126 }
1127 #endif
1128 
1129 #ifdef ID_S_RGBW_LIGHT
1130 void rgbwLight()
1131 {
1132 
1133  Serial.print("RGBW Light state is: " );
1134  Serial.println(rgbwState);
1135  send(msg_S_RGBW_LIGHT_V_RGBW.set(rgbwState.c_str()));
1136 
1137  Serial.print("RGBW Light Watt is: " );
1138  Serial.println(map(randNumber,1,100,0,150));
1139  send(msg_S_RGBW_LIGHT_V_WATT.set(map(randNumber,1,100,0,150)));
1140 
1141 }
1142 #endif
1143 
1144 #ifdef ID_S_COLOR_SENSOR
1145 void color()
1146 {
1147  String colorState;
1148 
1149  String red = String(random(0,256),HEX);
1150  String green = String(random(0,256),HEX);
1151  String blue = String(random(0,256),HEX);
1152 
1153  colorState=String(red + green + blue);
1154 
1155  Serial.print("Color state is: " );
1156  Serial.println(colorState);
1157  send(msg_S_COLOR_SENSOR_V_RGB.set(colorState.c_str()));
1158 
1159 }
1160 #endif
1161 
1162 #ifdef ID_S_HVAC
1163 void hvac()
1164 {
1165 
1166  // float hvac_SetPointHeat = 16.5;
1167  // float hvac_SetPointCool = 25.5;
1168  // String hvac_FlowState = "AutoChangeOver";
1169  // String hvac_FlowMode = "Auto";
1170  // String hvac_Speed = "Normal";
1171 
1172  Serial.print("HVAC Set Point Heat is: " );
1173  Serial.println(hvac_SetPointHeat);
1174  send(msg_S_HVAC_V_HVAC_SETPOINT_HEAT.set(hvac_SetPointHeat,1));
1175 
1176  Serial.print("HVAC Set Point Cool is: " );
1177  Serial.println(hvac_SetPointCool);
1178  send(msg_S_HVAC_V_HVAC_SETPOINT_COOL.set(hvac_SetPointCool,1));
1179 
1180  Serial.print("HVAC Flow State is: " );
1181  Serial.println(hvac_FlowState);
1182  send(msg_S_HVAC_V_HVAC_FLOW_STATET.set(hvac_FlowState.c_str()));
1183 
1184  Serial.print("HVAC Flow Mode is: " );
1185  Serial.println(hvac_FlowMode);
1186  send(msg_S_HVAC_V_HVAC_FLOW_MODE.set(hvac_FlowMode.c_str()));
1187 
1188  Serial.print("HVAC Speed is: " );
1189  Serial.println(hvac_Speed);
1190  send(msg_S_HVAC_V_HVAC_SPEED.set(hvac_Speed.c_str()));
1191 
1192 }
1193 #endif
1194 
1195 #ifdef ID_S_MULTIMETER
1196 void multimeter()
1197 {
1198  int impedance=map(randNumber,1,100,0,15000);
1199  int volt=map(randNumber,1,100,0,380);
1200  int amps=map(randNumber,1,100,0,16);
1201 
1202  Serial.print("Impedance is: " );
1203  Serial.println(impedance);
1204  send(msg_S_MULTIMETER_V_IMPEDANCE.set(impedance));
1205 
1206  Serial.print("Voltage is: " );
1207  Serial.println(volt);
1208  send(msg_S_MULTIMETER_V_VOLTAGE.set(volt));
1209 
1210  Serial.print("Current is: " );
1211  Serial.println(amps);
1212  send(msg_S_MULTIMETER_V_CURRENT.set(amps));
1213 
1214 }
1215 #endif
1216 
1217 #ifdef ID_S_SPRINKLER
1218 #endif
1219 #ifdef ID_S_WATER_LEAK
1220 #endif
1221 #ifdef ID_S_SOUND
1222 #endif
1223 #ifdef ID_S_VIBRATION
1224 #endif
1225 #ifdef ID_S_MOISTURE
1226 #endif
1227 
1228 #ifdef ID_S_MOISTURE
1229 void moisture()
1230 {
1231 
1232  Serial.print("Moisture level is: " );
1233  Serial.println(randNumber);
1234 
1235  send(msg_S_MOISTURE.set(randNumber));
1236 }
1237 #endif
1238 
1239 #ifdef ID_S_CUSTOM
1240 void custom()
1241 {
1242 
1243  Serial.print("Custom value is: " );
1244  Serial.println(randNumber);
1245 
1246  send(msg_S_CUSTOM_1.set(randNumber));
1247  send(msg_S_CUSTOM_2.set(randNumber));
1248  send(msg_S_CUSTOM_3.set(randNumber));
1249  send(msg_S_CUSTOM_4.set(randNumber));
1250  send(msg_S_CUSTOM_5.set(randNumber));
1251 
1252 }
1253 #endif
1254 
1255 
1256 void receive(const MyMessage &message)
1257 {
1258  switch (message.getType()) {
1259 #ifdef ID_S_ARMED
1260  case V_ARMED:
1261  isArmed = message.getBool();
1262  Serial.print("Incoming change for ID_S_ARMED:");
1263  Serial.print(message.getSensor());
1264  Serial.print(", New status: ");
1265  Serial.println((isArmed ? "Armed":"Disarmed" ));
1266 #ifdef ID_S_DOOR
1267  door();//temp ack for door
1268 #endif
1269 #ifdef ID_S_MOTION
1270  motion();//temp ack
1271 #endif
1272 #ifdef ID_S_SMOKE
1273  smoke();//temp ack
1274 #endif
1275  break;
1276 #endif
1277 
1278 
1279  case V_STATUS: // V_LIGHT:
1280 #ifdef ID_S_LIGHT
1281  if(message.getSensor()==ID_S_LIGHT) {
1282  isLightOn = message.getBool();
1283  Serial.print("Incoming change for ID_S_LIGHT:");
1284  Serial.print(message.getSensor());
1285  Serial.print(", New status: ");
1286  Serial.println((isLightOn ? "On":"Off"));
1287  light(); // temp ack
1288  }
1289 #endif
1290  // #ifdef ID_S_HEATER
1291  // if(message.getSensor() == ID_S_HEATER){
1292  // heater_status = message.getBool();
1293  // Serial.print("Incoming change for ID_S_HEATER:");
1294  // Serial.print(message.getSensor());
1295  // Serial.print(", New status: ");
1296  // Serial.println(heater_status);
1297  // heater();//temp ack
1298  // }
1299  // #endif
1300  break;
1301 
1302 
1303 #ifdef ID_S_DIMMER
1304  case V_DIMMER:
1305  if ((message.getInt()<0)||(message.getInt()>100)) {
1306  Serial.println( "V_DIMMER data invalid (should be 0..100)" );
1307  break;
1308  }
1309  dimmerVal= message.getInt();
1310  Serial.print("Incoming change for ID_S_DIMMER:");
1311  Serial.print(message.getSensor());
1312  Serial.print(", New status: ");
1313  Serial.println(message.getInt());
1314  dimmer();// temp ack
1315  break;
1316 #endif
1317 
1318 #ifdef ID_S_COVER
1319  case V_UP:
1320  coverState=1;
1321  Serial.print("Incoming change for ID_S_COVER:");
1322  Serial.print(message.getSensor());
1323  Serial.print(", New status: ");
1324  Serial.println("V_UP");
1325  cover(); // temp ack
1326  break;
1327 
1328  case V_DOWN:
1329  coverState=-1;
1330  Serial.print("Incoming change for ID_S_COVER:");
1331  Serial.print(message.getSensor());
1332  Serial.print(", New status: ");
1333  Serial.println("V_DOWN");
1334  cover(); //temp ack
1335  break;
1336 
1337  case V_STOP:
1338  coverState=0;
1339  Serial.print("Incoming change for ID_S_COVER:");
1340  Serial.print(message.getSensor());
1341  Serial.print(", New status: ");
1342  Serial.println("V_STOP");
1343  cover(); //temp ack
1344  break;
1345 #endif
1346 
1347 
1348  case V_HVAC_SETPOINT_HEAT:
1349 
1350 #ifdef ID_S_HEATER
1351  if(message.getSensor() == ID_S_HEATER) {
1352  heater_setpoint=message.getFloat();
1353 
1354  Serial.print("Incoming set point for ID_S_HEATER:");
1355  Serial.print(message.getSensor());
1356  Serial.print(", New status: ");
1357  Serial.println(heater_setpoint,1);
1358  heater();//temp ack
1359  }
1360 #endif
1361 
1362 #ifdef ID_S_HVAC
1363  if(message.getSensor() == ID_S_HVAC) {
1364  hvac_SetPointHeat=message.getFloat();
1365  Serial.print("Incoming set point for ID_S_HVAC:");
1366  Serial.print(message.getSensor());
1367  Serial.print(", New status: ");
1368  Serial.println(hvac_SetPointHeat,1);
1369  hvac();//temp ack
1370  }
1371 #endif
1372  break;
1373 
1374  case V_HVAC_FLOW_STATE:
1375 #ifdef ID_S_HEATER
1376  if(message.getSensor() == ID_S_HEATER) {
1377  heater_flow_state=message.getString();
1378  Serial.print("Incoming flow state change for ID_S_HEATER:");
1379  Serial.print(message.getSensor());
1380  Serial.print(", New status: ");
1381  Serial.println(heater_flow_state);
1382  heater();//temp ack
1383  }
1384 #endif
1385 
1386 #ifdef ID_S_HVAC
1387  if(message.getSensor() == ID_S_HVAC) {
1388  hvac_FlowState=message.getString();
1389 
1390  Serial.print("Incoming set point for ID_S_HVAC:");
1391  Serial.print(message.getSensor());
1392  Serial.print(", New status: ");
1393  Serial.println(hvac_FlowState);
1394  hvac();//temp ack
1395  }
1396 #endif
1397  break;
1398 
1399 #ifdef ID_S_LOCK
1400  case V_LOCK_STATUS:
1401  isLocked = message.getBool();
1402  Serial.print("Incoming change for ID_S_LOCK:");
1403  Serial.print(message.getSensor());
1404  Serial.print(", New status: ");
1405  Serial.println(message.getBool()?"Locked":"Unlocked");
1406  lock(); //temp ack
1407  break;
1408 #endif
1409 
1410 #ifdef ID_S_IR
1411  case V_IR_SEND:
1412  irVal = message.getLong();
1413  Serial.print("Incoming change for ID_S_IR:");
1414  Serial.print(message.getSensor());
1415  Serial.print(", New status: ");
1416  Serial.println(irVal);
1417  ir(); // temp ack
1418  break;
1419  case V_IR_RECEIVE:
1420  irVal = message.getLong();
1421  Serial.print("Incoming change for ID_S_IR:");
1422  Serial.print(message.getSensor());
1423  Serial.print(", New status: ");
1424  Serial.println(irVal);
1425  ir(); // temp ack
1426  break;
1427 #endif
1428 
1429 #ifdef ID_S_SCENE_CONTROLLER
1430  case V_SCENE_ON:
1431  sceneVal = message.getInt();
1432  Serial.print("Incoming change for ID_S_SCENE_CONTROLLER:");
1433  Serial.print(message.getSensor());
1434  Serial.print(", New status: ");
1435  Serial.print(scenes[sceneVal]);
1436  Serial.println(" On");
1437  scene();// temp ack
1438  break;
1439  case V_SCENE_OFF:
1440  sceneVal = message.getInt();
1441  Serial.print("Incoming change for ID_S_SCENE_CONTROLLER:");
1442  Serial.print(message.getSensor());
1443  Serial.print(", New status: ");
1444  Serial.print(scenes[sceneVal]);
1445  Serial.println(" Off");
1446  scene();// temp ack
1447  break;
1448 #endif
1449 
1450 #ifdef ID_S_RGB_LIGHT
1451  case V_RGB:
1452  rgbState=message.getString();
1453  Serial.print("Incoming flow state change for ID_S_RGB_LIGHT:");
1454  Serial.print(message.getSensor());
1455  Serial.print(", New status: ");
1456  Serial.println(rgbState);
1457  rgbLight(); // temp ack
1458 
1459  break;
1460 #endif
1461 
1462 #ifdef ID_S_RGBW_LIGHT
1463  case V_RGBW:
1464  rgbwState=message.getString();
1465  Serial.print("Incoming flow state change for ID_S_RGBW_LIGHT:");
1466  Serial.print(message.getSensor());
1467  Serial.print(", New status: ");
1468  Serial.println(rgbwState);
1469  rgbwLight();
1470  break;
1471 #endif
1472 
1473 #ifdef ID_S_HVAC
1474  // hvac_SetPointHeat
1475  // hvac_SetPointCool
1476  // hvac_FlowState
1477  // hvac_FlowMode
1478  // hvac_Speed
1479 
1480  case V_HVAC_SETPOINT_COOL:
1481  hvac_SetPointCool=message.getFloat();
1482 
1483  Serial.print("Incoming set point for ID_S_HVAC:");
1484  Serial.print(message.getSensor());
1485  Serial.print(", New status: ");
1486  Serial.println(hvac_SetPointCool,1);
1487  hvac();//temp ack
1488  break;
1489 
1490  case V_HVAC_FLOW_MODE:
1491  hvac_Speed=message.getString();
1492 
1493  Serial.print("Incoming set point for ID_S_HVAC:");
1494  Serial.print(message.getSensor());
1495  Serial.print(", New status: ");
1496  Serial.println(hvac_Speed);
1497  hvac();//temp ack
1498  break;
1499 
1500  case V_HVAC_SPEED:
1501  hvac_FlowMode=message.getString();
1502 
1503  Serial.print("Incoming set point for ID_S_HVAC:");
1504  Serial.print(message.getSensor());
1505  Serial.print(", New status: ");
1506  Serial.println(hvac_FlowMode);
1507  hvac();//temp ack
1508  break;
1509 #endif
1510 
1511  default:
1512  Serial.print("Unknown/Unimplemented message type: ");
1513  Serial.println(message.getType());
1514  }
1515 
1516 }
MyMessage::getInt
int16_t getInt(void) const
Get signed 16-bit integer payload.
sendSketchInfo
bool sendSketchInfo(const char *name, const char *version, const bool requestEcho=false)
receiveTime
void receiveTime(uint32_t controllerTime)
Callback for incoming time messages.
Definition: MockMySensors.ino:745
MyMessage::getSensor
uint8_t getSensor(void) const
Get sensor ID of message.
receive
void receive(const MyMessage &message)
Callback for incoming messages.
Definition: MockMySensors.ino:1256
loop
void loop()
Main loop.
Definition: MockMySensors.ino:586
presentation
void presentation()
Node presentation.
Definition: MockMySensors.ino:365
getControllerConfig
controllerConfig_t getControllerConfig(void)
MyMessage::getLong
int32_t getLong(void) const
Get signed 32-bit integer payload.
MyMessage::set
MyMessage & set(const void *payload, const size_t length)
Set entire payload.
MyMessage::getString
char * getString(char *buffer) const
Copy the payload into the supplied buffer.
send
bool send(MyMessage &msg, const bool requestEcho=false)
MyMessage::getType
uint8_t getType(void) const
Get message type.
present
bool present(const uint8_t sensorId, const mysensors_sensor_t sensorType, const char *description="", const bool requestEcho=false)
setup
void setup()
Called after node initialises but before main loop.
Definition: MockMySensors.ino:356
requestTime
bool requestTime(const bool requestEcho=false)
wait
void wait(const uint32_t waitingMS)
sendBatteryLevel
bool sendBatteryLevel(const uint8_t level, const bool requestEcho=false)
MyMessage::getFloat
float getFloat(void) const
Get float payload.
MySensors.h
API declaration for MySensors.
MyMessage::getBool
bool getBool(void) const
Get bool payload.
MyMessage
MyMessage is used to create, manipulate, send and read MySensors messages.
Definition: MyMessage.h:289
controllerConfig_t::isMetric
uint8_t isMetric
Flag indicating if metric or imperial measurements are used.
Definition: MySensorsCore.h:95