Add mysensors types (#1031)
* Add more types. * Fix some rendering issues.
This commit is contained in:
parent
2fffb5d097
commit
bb9533e546
6 changed files with 91 additions and 71 deletions
|
@ -2,14 +2,13 @@
|
|||
layout: page
|
||||
title: "MySensors HVAC"
|
||||
description: "Instructions how to integrate MySensors climate into Home Assistant."
|
||||
date: 2016-09-14 18:20 +0100
|
||||
date: 2016-10-01 15:00 +0200
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
logo: mysensors.png
|
||||
ha_category: Climate
|
||||
featured: false
|
||||
ha_release: 0.29
|
||||
---
|
||||
|
||||
|
@ -19,18 +18,18 @@ The following actuator types are supported:
|
|||
|
||||
##### MySensors version 1.5 and higher
|
||||
|
||||
S_TYPE | V_TYPE
|
||||
------------|-------------
|
||||
S_HVAC | V_HVAC_FLOW_STATE*, V_HVAC_SETPOINT_HEAT, V_HVAC_SETPOINT_COOL, V_HVAC_SPEED
|
||||
S_TYPE | V_TYPE
|
||||
-------|-----------------------------------------------------------------------------
|
||||
S_HVAC | V_HVAC_FLOW_STATE*, V_HVAC_SETPOINT_HEAT, V_HVAC_SETPOINT_COOL, V_HVAC_SPEED
|
||||
|
||||
V_HVAC_FLOW_STATE is mapped to the state of the Climate component in HA as follows:
|
||||
|
||||
Home Assistant State | MySensors State
|
||||
-----------------------|----------------------
|
||||
STATE_COOL | CoolOn
|
||||
STATE_HEAT | HeatOn
|
||||
STATE_AUTO | Off
|
||||
STATE_OFF | AutoChangeOver
|
||||
Home Assistant State | MySensors State
|
||||
---------------------|----------------
|
||||
STATE_COOL | CoolOn
|
||||
STATE_HEAT | HeatOn
|
||||
STATE_AUTO | Off
|
||||
STATE_OFF | AutoChangeOver
|
||||
|
||||
Currently humidity, away_mode, aux_heat, swing_mode is not supported. This will be included in later versions as feasible.
|
||||
|
||||
|
@ -44,67 +43,72 @@ For more information, visit the [serial api] of MySensors.
|
|||
|
||||
```cpp
|
||||
/*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
*/
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*/
|
||||
|
||||
#include <MySensor.h>
|
||||
/* Include all the other Necessary code here. The example code is limited to message exchange for mysensors with the controller (ha)*/
|
||||
/*
|
||||
* Include all the other Necessary code here.
|
||||
* The example code is limited to message exchange for mysensors
|
||||
* with the controller (ha).
|
||||
*/
|
||||
|
||||
#define CHILD_ID_HVAC 0 // childId
|
||||
MyMessage msgHVACSetPointC(CHILD_ID_HVAC, V_HVAC_SETPOINT_COOL);
|
||||
MyMessage msgHVACSpeed(CHILD_ID_HVAC, V_HVAC_SPEED);
|
||||
MyMessage msgHVACFlowState(CHILD_ID_HVAC, V_HVAC_FLOW_STATE);
|
||||
|
||||
/* Include all the other Necessary code here. The example code is limited to message exchange for mysensors with the controller (ha)*/
|
||||
/*
|
||||
* Include all the other Necessary code here.
|
||||
* The example code is limited to message exchange for mysensors
|
||||
* with the controller (ha).
|
||||
*/
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Startup and initialize MySensors library.
|
||||
// Set callback for incoming messages.
|
||||
gw.begin(incomingMessage);
|
||||
|
||||
// Startup and initialize MySensors library. Set callback for incoming messages.
|
||||
gw.begin(incomingMessage);
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
gw.sendSketchInfo("HVAC", "0.1");
|
||||
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
gw.sendSketchInfo("HVAC", "0.1");
|
||||
|
||||
gw.present(CHILD_ID_HVAC, S_HVAC, "Thermostat");
|
||||
gw.send(msgHVACFlowState.set("Off"));
|
||||
gw.send(msgHVACSetPointC.set(target_temp));
|
||||
gw.send(msgHVACSpeed.set("Max"));
|
||||
}
|
||||
|
||||
void incomingMessage(const MyMessage &message) {
|
||||
String recvData = message.data;
|
||||
recvData.trim();
|
||||
switch (message.type) {
|
||||
case V_HVAC_SPEED:
|
||||
if(recvData.equalsIgnoreCase("auto")) fan_speed = 0;
|
||||
else if(recvData.equalsIgnoreCase("min")) fan_speed = 1;
|
||||
else if(recvData.equalsIgnoreCase("normal")) fan_speed = 2;
|
||||
else if(recvData.equalsIgnoreCase("max")) fan_speed = 3;
|
||||
processHVAC();
|
||||
break;
|
||||
case V_HVAC_SETPOINT_COOL:
|
||||
target_temp = message.getFloat();
|
||||
processHVAC();
|
||||
break;
|
||||
case V_HVAC_FLOW_STATE:
|
||||
if(recvData.equalsIgnoreCase("coolon") && (!Present_Power_On )){
|
||||
togglePower();
|
||||
}
|
||||
else if(recvData.equalsIgnoreCase("off") && Present_Power_On ){
|
||||
togglePower();
|
||||
}
|
||||
break;
|
||||
}
|
||||
gw.present(CHILD_ID_HVAC, S_HVAC, "Thermostat");
|
||||
gw.send(msgHVACFlowState.set("Off"));
|
||||
gw.send(msgHVACSetPointC.set(target_temp));
|
||||
gw.send(msgHVACSpeed.set("Max"));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Process incoming messages (like config from server)
|
||||
gw.process();
|
||||
}
|
||||
|
||||
// Process incoming messages (like config from server)
|
||||
gw.process();
|
||||
|
||||
void incomingMessage(const MyMessage &message) {
|
||||
String recvData = message.data;
|
||||
recvData.trim();
|
||||
switch (message.type) {
|
||||
case V_HVAC_SPEED:
|
||||
if(recvData.equalsIgnoreCase("auto")) fan_speed = 0;
|
||||
else if(recvData.equalsIgnoreCase("min")) fan_speed = 1;
|
||||
else if(recvData.equalsIgnoreCase("normal")) fan_speed = 2;
|
||||
else if(recvData.equalsIgnoreCase("max")) fan_speed = 3;
|
||||
processHVAC();
|
||||
break;
|
||||
case V_HVAC_SETPOINT_COOL:
|
||||
target_temp = message.getFloat();
|
||||
processHVAC();
|
||||
break;
|
||||
case V_HVAC_FLOW_STATE:
|
||||
if(recvData.equalsIgnoreCase("coolon") && (!Present_Power_On )){
|
||||
togglePower();
|
||||
}
|
||||
else if(recvData.equalsIgnoreCase("off") && Present_Power_On ){
|
||||
togglePower();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue