Skip to content

Commit 533c26b

Browse files
committed
Merge pull request #170 from gizmocuz/master
MyMessage.h comments fixed / MockMySensors changes to get it working in 1.5
2 parents 841326d + 3b531e7 commit 533c26b

File tree

3 files changed

+75
-103
lines changed

3 files changed

+75
-103
lines changed

libraries/MySensors/MyMessage.h

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ typedef enum {
5858
S_UV, // Uv sensor, V_UV
5959
S_WEIGHT, // Personal scale sensor, V_WEIGHT, V_IMPEDANCE
6060
S_POWER, // Power meter, V_WATT, V_KWH
61-
S_HEATER, // Header device, V_HVAC_SETPOINT_HEAT, V_HVAC_FLOW_STATE
61+
S_HEATER, // Header device, V_HVAC_SETPOINT_HEAT, V_HVAC_FLOW_STATE, V_TEMP
6262
S_DISTANCE, // Distance sensor, V_DISTANCE
6363
S_LIGHT_LEVEL, // Light level sensor, V_LIGHT_LEVEL (uncalibrated in percentage), V_LEVEL (light level in lux)
6464
S_ARDUINO_NODE, // Used (internally) for presenting a non-repeating Arduino node
@@ -73,7 +73,7 @@ typedef enum {
7373
S_RGB_LIGHT, // RGB light. Send color component data using V_RGB. Also supports V_WATT
7474
S_RGBW_LIGHT, // RGB light with an additional White component. Send data using V_RGBW. Also supports V_WATT
7575
S_COLOR_SENSOR, // Color sensor, send color information using V_RGB
76-
S_HVAC, // Thermostat/HVAC device. V_HVAC_SETPOINT_HEAT, V_HVAC_SETPOINT_COLD, V_HVAC_FLOW_STATE, V_HVAC_FLOW_MODE
76+
S_HVAC, // Thermostat/HVAC device. V_HVAC_SETPOINT_HEAT, V_HVAC_SETPOINT_COLD, V_HVAC_FLOW_STATE, V_HVAC_FLOW_MODE, V_TEMP
7777
S_MULTIMETER, // Multimeter device, V_VOLTAGE, V_CURRENT, V_IMPEDANCE
7878
S_SPRINKLER, // Sprinkler, V_STATUS (turn on/off), V_TRIPPED (if fire detecting device)
7979
S_WATER_LEAK, // Water leak sensor, V_TRIPPED, V_ARMED
@@ -84,42 +84,42 @@ typedef enum {
8484

8585
// Type of sensor data (for set/req/ack messages)
8686
typedef enum {
87-
V_TEMP, // S_TEMP
88-
V_HUM, // S_HUM
89-
V_STATUS, // S_LIGHT, S_DIMMER, S_SPRINKLER, S_HVAC, S_HEATER. Used for setting binary (on/off) status. 1=on, 0=off
87+
V_TEMP, // S_TEMP. Temperature S_TEMP, S_HEATER, S_HVAC
88+
V_HUM, // S_HUM. Humidity
89+
V_STATUS, // S_LIGHT, S_DIMMER, S_SPRINKLER, S_HVAC, S_HEATER. Used for setting/reporting binary (on/off) status. 1=on, 0=off
9090
V_LIGHT=2, // Same as V_STATUS
91-
V_PERCENTAGE, // S_DIMMER. Used for sending a percentage value (0-100).
91+
V_PERCENTAGE, // S_DIMMER. Used for sending a percentage value 0-100 (%).
9292
V_DIMMER=3, // S_DIMMER. Same as V_PERCENTAGE.
93-
V_PRESSURE, // S_BARO
94-
V_FORECAST, // S_BARO
95-
V_RAIN, // S_RAIN
96-
V_RAINRATE, // S_RAIN
97-
V_WIND, // S_WIND
98-
V_GUST, // S_WIND
99-
V_DIRECTION, // S_WIND
100-
V_UV, // S_UV
101-
V_WEIGHT, // S_WEIGHT
102-
V_DISTANCE, // S_DISTANCE
103-
V_IMPEDANCE, // S_MULTIMETER, S_WEIGHT
104-
V_ARMED, // S_DOOR, S_MOTION, S_SMOKE, S_SPRINKLER
105-
V_TRIPPED, // S_DOOR, S_MOTION, S_SMOKE, S_SPRINKLER (for sprinklers with fire detection)
106-
V_WATT, // S_POWER, S_LIGHT, S_DIMMER
107-
V_KWH, // S_POWER
108-
V_SCENE_ON, // S_SCENE_CONTROLLER
109-
V_SCENE_OFF, // S_SCENE_CONTROLLER
93+
V_PRESSURE, // S_BARO. Atmospheric Pressure
94+
V_FORECAST, // S_BARO. Whether forecast. string of "stable", "sunny", "cloudy", "unstable", "thunderstorm" or "unknown"
95+
V_RAIN, // S_RAIN. Amount of rain
96+
V_RAINRATE, // S_RAIN. Rate of rain
97+
V_WIND, // S_WIND. Wind speed
98+
V_GUST, // S_WIND. Gust
99+
V_DIRECTION, // S_WIND. Wind direction 0-360 (degrees)
100+
V_UV, // S_UV. UV light level
101+
V_WEIGHT, // S_WEIGHT. Weight(for scales etc)
102+
V_DISTANCE, // S_DISTANCE. Distance
103+
V_IMPEDANCE, // S_MULTIMETER, S_WEIGHT. Impedance value
104+
V_ARMED, // S_DOOR, S_MOTION, S_SMOKE, S_SPRINKLER. Armed status of a security sensor. 1 = Armed, 0 = Bypassed
105+
V_TRIPPED, // S_DOOR, S_MOTION, S_SMOKE, S_SPRINKLER, S_WATER_LEAK, S_SOUND, S_VIBRATION, S_MOISTURE. Tripped status of a security sensor. 1 = Tripped, 0
106+
V_WATT, // S_POWER, S_LIGHT, S_DIMMER, S_RGB, S_RGBW. Watt value for power meters
107+
V_KWH, // S_POWER. Accumulated number of KWH for a power meter
108+
V_SCENE_ON, // S_SCENE_CONTROLLER. Turn on a scene
109+
V_SCENE_OFF, // S_SCENE_CONTROLLER. Turn of a scene
110110
V_HEATER, // Deprecated. Use V_HVAC_FLOW_STATE instead.
111-
V_HVAC_FLOW_STATE=21, // HVAC flow state ("Off", "HeatOn", "CoolOn", or "AutoChangeOver"). S_HEATER, S_HVAC
112-
V_HVAC_SPEED, // HVAC/Heater fan speed ("Min", "Normal", "Max", "Auto")
113-
V_LIGHT_LEVEL, // Used for sending light level in uncalibrated percentage. See also V_LEVEL (light level in lux). S_LIGHT_LEVEL
111+
V_HVAC_FLOW_STATE=21, // S_HEATER, S_HVAC. HVAC flow state ("Off", "HeatOn", "CoolOn", or "AutoChangeOver")
112+
V_HVAC_SPEED, // S_HVAC, S_HEATER. HVAC/Heater fan speed ("Min", "Normal", "Max", "Auto")
113+
V_LIGHT_LEVEL, // S_LIGHT_LEVEL. Uncalibrated light level. 0-100%. Use V_LEVEL for light level in lux
114114
V_VAR1, V_VAR2, V_VAR3, V_VAR4, V_VAR5,
115-
V_UP, // S_COVER
116-
V_DOWN, // S_COVER
117-
V_STOP, // S_COVER
118-
V_IR_SEND, // S_IR
119-
V_IR_RECEIVE, // S_IR
120-
V_FLOW, // S_WATER
121-
V_VOLUME, // S_WATER
122-
V_LOCK_STATUS, // S_LOCK
115+
V_UP, // S_COVER. Window covering. Up
116+
V_DOWN, // S_COVER. Window covering. Down
117+
V_STOP, // S_COVER. Window covering. Stop
118+
V_IR_SEND, // S_IR. Send out an IR-command
119+
V_IR_RECEIVE, // S_IR. This message contains a received IR-command
120+
V_FLOW, // S_WATER. Flow of water (in meter)
121+
V_VOLUME, // S_WATER. Water volume
122+
V_LOCK_STATUS, // S_LOCK. Set or get lock status. 1=Locked, 0=Unlocked
123123
V_LEVEL, // S_DUST, S_AIR_QUALITY, S_SOUND (dB), S_VIBRATION (hz), S_LIGHT_LEVEL (lux)
124124
V_VOLTAGE, // S_MULTIMETER
125125
V_CURRENT, // S_MULTIMETER
@@ -128,15 +128,16 @@ typedef enum {
128128
// Sent as ASCII hex: RRGGBB (RR=red, GG=green, BB=blue component)
129129
V_RGBW, // S_RGBW_LIGHT
130130
// Used for sending color information to multi color LED lighting.
131-
// Sent as ASCII hex: RRGGBBWW (WW=while component)
131+
// Sent as ASCII hex: RRGGBBWW (WW=white component)
132132
V_ID, // S_TEMP
133133
// Used for sending in sensors hardware ids (i.e. OneWire DS1820b).
134-
V_UNIT_PREFIX, // Allows sensors to send in a string representing the
135-
// unit prefix to be displayed in GUI, not parsed by controller! E.g. cm, m, km, inch.
136-
// Can be used for S_DISTANCE or gas concentration (S_DUST, S_AIR_QUALITY)
137-
V_HVAC_SETPOINT_COOL, // HVAC cool setpoint (Integer between 0-100). S_HVAC
138-
V_HVAC_SETPOINT_HEAT, // HVAC/Heater setpoint (Integer between 0-100). S_HEATER, S_HVAC
139-
V_HVAC_FLOW_MODE, // Flow mode for HVAC ("Auto", "ContinuousOn", "PeriodicOn"). S_HVAC
134+
V_UNIT_PREFIX, // S_DUST, S_AIR_QUALITY
135+
// Allows sensors to send in a string representing the
136+
// unit prefix to be displayed in GUI, not parsed by controller! E.g. cm, m, km, inch.
137+
// Can be used for S_DISTANCE or gas concentration
138+
V_HVAC_SETPOINT_COOL, // S_HVAC. HVAC cool setpoint (Integer between 0-100)
139+
V_HVAC_SETPOINT_HEAT, // S_HEATER, S_HVAC. HVAC/Heater setpoint (Integer between 0-100)
140+
V_HVAC_FLOW_MODE, // S_HVAC. Flow mode for HVAC ("Auto", "ContinuousOn", "PeriodicOn")
140141

141142
} mysensor_data;
142143

libraries/MySensors/examples/MockMySensors/MockMySensors.ino

Lines changed: 31 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,29 @@
11
/*
2-
* MockMySensors
2+
* FakeMySensors
33
*
44
* This skecth is intended to crate fake sensors which register and respond to the controller
55
*
6-
* Barduino 2015
6+
* Barduino, GizMoCuz 2015
77
*/
88

9-
#include <MySigningNone.h>
10-
#include <MyTransportRFM69.h>
11-
#include <MyTransportNRF24.h>
12-
#include <MyHwATMega328.h>
13-
#include <MySigningAtsha204Soft.h>
14-
#include <MySigningAtsha204.h>
15-
16-
#include <SPI.h>
179
#include <MySensor.h>
18-
#include <MyMessage.h>
10+
#include <SPI.h>
1911

20-
#define RADIO_ERROR_LED_PIN 4 // Error led pin
21-
#define RADIO_RX_LED_PIN 6 // Receive led pin
22-
#define RADIO_TX_LED_PIN 5 // the PCB, on board LED
12+
// SPI Pins
13+
#define CE_PIN 9
14+
#define CS_PIN 10
2315

2416
// Wait times
2517
#define LONG_WAIT 500
2618
#define SHORT_WAIT 50
2719

2820
#define SKETCH_NAME "FakeMySensors "
29-
#define SKETCH_VERSION "v0.2"
30-
31-
// Define Sensors ids
32-
/* S_DOOR, S_MOTION, S_SMOKE, S_LIGHT, S_DIMMER, S_COVER, S_TEMP, S_HUM, S_BARO, S_WIND,
33-
S_RAIN, S_UV, S_WEIGHT, S_POWER, S_HEATER, S_DISTANCE, S_LIGHT_LEVEL, S_ARDUINO_NODE,
34-
S_ARDUINO_REPEATER_NODE, S_LOCK, S_IR, S_WATER, S_AIR_QUALITY, S_CUSTOM, S_DUST,
35-
S_SCENE_CONTROLLER
36-
*/
21+
#define SKETCH_VERSION "v0.3"
3722

3823
////#define ID_S_ARDUINO_NODE //auto defined in initialization
3924
////#define ID_S_ARDUINO_REPEATER_NODE //auto defined in initialization
4025

41-
// Some of these ID's have not been updated for v1.5. Uncommenting too many of them
42-
// will make the sketch too large for a pro mini's memory so it's probably best to try
43-
// one at a time.
44-
#define ID_S_DOOR 1
26+
//#define ID_S_DOOR 1
4527
//#define ID_S_MOTION 2
4628
//#define ID_S_SMOKE 3
4729
//#define ID_S_LIGHT 4
@@ -51,11 +33,11 @@
5133
//#define ID_S_HUM 8
5234
//#define ID_S_BARO 9
5335
//#define ID_S_WIND 10
54-
//#define ID_S_RAIN 11
36+
//#define ID_S_RAIN 11
5537
//#define ID_S_UV 12
5638
//#define ID_S_WEIGHT 13
5739
//#define ID_S_POWER 14
58-
//#define ID_S_HEATER 15
40+
//#define ID_S_HEATER 15 <<-- not correctly implemented (1.5 API)
5941
//#define ID_S_DISTANCE 16
6042
//#define ID_S_LIGHT_LEVEL 17
6143
//#define ID_S_LOCK 18
@@ -67,29 +49,12 @@
6749
//#define ID_S_CUSTOM 24
6850

6951
// Global Vars
70-
unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds)
52+
unsigned long SLEEP_TIME = 12000; // Sleep time between reads (in milliseconds)
7153
boolean metric = true;
7254
long randNumber;
7355

7456
// Instanciate MySersors Gateway
75-
MyTransportNRF24 transport(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);
76-
//MyTransportRFM69 transport;
77-
78-
// Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
79-
//MySigningNone signer;
80-
//MySigningAtsha204Soft signer;
81-
//MySigningAtsha204 signer;
82-
83-
// Hardware profile
84-
MyHwATMega328 hw;
85-
86-
// Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
87-
// To use LEDs blinking, uncomment WITH_LEDS_BLINKING in MyConfig.h
88-
#ifdef WITH_LEDS_BLINKING
89-
MySensor gw(transport, hw /*, signer*/, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
90-
#else
91-
MySensor gw(transport, hw /*, signer*/);
92-
#endif
57+
MySensor gw;
9358

9459
//Instanciate Messages objects
9560

@@ -161,8 +126,10 @@ MySensor gw(transport, hw /*, signer*/);
161126
#endif
162127

163128
#ifdef ID_S_HEATER
164-
MyMessage msg_S_HEATER_M(ID_S_HEATER,V_HEATER);
165-
MyMessage msg_S_HEATER_S(ID_S_HEATER,V_HEATER_SW);
129+
float current_set_point=21.5;
130+
MyMessage msg_S_HEATER_SP(ID_S_HEATER,V_HVAC_SETPOINT_HEAT);
131+
MyMessage msg_S_HEATER_F(ID_S_HEATER,V_HVAC_SETPOINT_HEAT);
132+
MyMessage msg_S_HEATER_T(ID_S_HEATER,V_TEMP);
166133
#endif
167134

168135
#ifdef ID_S_DISTANCE
@@ -188,11 +155,11 @@ MySensor gw(transport, hw /*, signer*/);
188155
#endif
189156

190157
#ifdef ID_S_AIR_QUALITY
191-
MyMessage msg_S_AIR_QUALITY(ID_S_AIR_QUALITY,V_VAR1);
158+
MyMessage msg_S_AIR_QUALITY(ID_S_AIR_QUALITY,V_LEVEL);
192159
#endif
193160

194161
#ifdef ID_S_DUST
195-
MyMessage msg_S_DUST(ID_S_DUST,V_DUST_LEVEL);
162+
MyMessage msg_S_DUST(ID_S_DUST,V_LEVEL);
196163
#endif
197164

198165
#ifdef ID_S_SCENE_CONTROLLER
@@ -268,13 +235,13 @@ void setup()
268235
#endif
269236

270237
#ifdef ID_S_COVER
271-
Serial.println(" S_COVER";
238+
Serial.println(" S_COVER");
272239
gw.present(ID_S_COVER,S_COVER);
273240
gw.wait(SHORT_WAIT);
274241
#endif
275242

276243
#ifdef ID_S_TEMP
277-
Serial.println(" S_TMEP");
244+
Serial.println(" S_TEMP");
278245
gw.present(ID_S_TEMP,S_TEMP);
279246
gw.wait(SHORT_WAIT);
280247
#endif
@@ -408,7 +375,7 @@ void loop()
408375
gw.wait(LONG_WAIT);
409376

410377
//Read Sensors
411-
#ifdef S_ID_DOOR
378+
#ifdef ID_S_DOOR
412379
door();
413380
#endif
414381

@@ -519,9 +486,7 @@ void receiveTime(unsigned long controllerTime) {
519486

520487
}
521488

522-
//void door(){}
523-
524-
#ifdef S_ID_DOOR
489+
#ifdef ID_S_DOOR
525490
void door(){
526491

527492
Serial.print("Door is: " );
@@ -650,7 +615,7 @@ void hum(){
650615
void baro(){
651616

652617
const char *weather[] = {"stable","sunny","cloudy","unstable","thunderstorm","unknown"};
653-
long pressure = map(randNumber,1,100,87000,108600);
618+
long pressure = map(randNumber,1,100,900,1200);
654619
int forecast = map(randNumber,1,100,0,5);
655620

656621
Serial.print("Atmosferic Pressure is: " );
@@ -753,8 +718,9 @@ void power(){
753718

754719
#ifdef ID_S_HEATER
755720
void heater(){
756-
int heater_mode = gw.loadState(ID_S_HEATER);
757-
bool heater_switch = gw.loadState(ID_S_HEATER+1);
721+
int heater_set_point = gw.loadState(ID_S_HEATER);
722+
int heater_flow_state = gw.loadState(ID_S_HEATER+1);
723+
int heater_temp = gw.loadState(ID_S_HEATER+2);
758724

759725
Serial.print("Heater mode is: " );
760726

@@ -781,6 +747,11 @@ void heater(){
781747
Serial.println(heater_switch?"On":"Off");
782748

783749
gw.send(msg_S_HEATER_S.set(heater_switch));
750+
751+
Serial.print("Heater Temperature is: " );
752+
Serial.println(map(randNumber,1,100,0,45));
753+
754+
gw.send(msg_S_HEATER_T.set(map(randNumber,1,100,0,45)));
784755

785756
}
786757
#endif

libraries/MySensors/examples/MockMySensors/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Arduino sketch to fake sensor for the MySensors Library
33

44
This skecth is intended to crate fake sensors which register and respond to the controller
55

6-
Barduino 2015
6+
Barduino, GizMoCuz 2015
77
-----------------
88

99
Comment/Uncomment the sensors you would like to test
@@ -12,4 +12,4 @@ Arduino Uno R3 can support about 12 sensors before it runs out of memory.
1212
You probably need to turn of the MySensor Lib debug to save some memory
1313

1414
Nest step will be to remove the read/write to the eprom
15-
and extend to support the v1.5 sensors
15+
and extend 'ID_S_HEATER' to support the v1.5 API

0 commit comments

Comments
 (0)