Hey @BearWithBeard
I'd not put in a version:
as I'd assumed it would default to most recent... those assumptions always get you!
Pretty much working now, many thanks!
Hey @BearWithBeard
I'd not put in a version:
as I'd assumed it would default to most recent... those assumptions always get you!
Pretty much working now, many thanks!
Ignore me... the mysensors API version was set to 1.4
Ignore me... the mysensors API version was set to 1.4
// -*- mode: c -*-
#include "HeatPump.h"
HeatPump hp;
#define MY_NODE_ID 250
// Enable and select radio type attached
#define MY_RADIO_RFM69
#define MY_RFM69_NEW_DRIVER
#define MY_RFM69_FREQUENCY (RFM69_433MHZ)
#define MY_IS_RFM69HW 1
#define MY_RFM69_IRQ_PIN 3
#include <MySensors.h>
#define CHILD_POWER 0
#define CHILD_HVAC 1
#define CHILD_VANE 5
#define CHILD_STAT 6
bool metric = true;
unsigned long lastTempSend;
const unsigned long SEND_ROOM_TEMP_INTERVAL_MS = 120000;
// Power [ON,OFF]
MyMessage msgPower(CHILD_POWER, V_STATUS);
// Temp set point
MyMessage msgSTemp(CHILD_HVAC, V_HVAC_SETPOINT_HEAT);
// Room Temp
MyMessage msgRTemp(CHILD_HVAC, V_TEMP);
// Fan Speed [QUIET,2,4,AUTO]
// my sensors -> HA ("Min", "Normal", "Max", "Auto")
MyMessage msgFanSp(CHILD_HVAC, V_HVAC_SPEED);
// Mode [Heat,Dry,Cool,Auto,?IDLE?]
// mysensors -> HA "Off", "HeatOn", "CoolOn", or "AutoChangeOver"
MyMessage msgMode(CHILD_HVAC, V_HVAC_FLOW_STATE);
// Vane Direction [AUTO,1,2,3,4,5,SWING]
// mysensors -> HA ????
MyMessage msgVane(CHILD_VANE, V_VAR1);
// Operating [YES, NO]
// mysensors -> HA TEXT
MyMessage msgStat(CHILD_STAT, V_TEXT);
const char* fanHA2HP(const char* val) {
if (strcmp(val,"Min") == 0) return "QUIET";
if (strcmp(val,"Normal") == 0) return "2";
if (strcmp(val,"Max") == 0) return "4";
if (strcmp(val,"Auto") == 0) return "AUTO";
return "2";
}
const char* fanHP2HA(const char* val) {
if (strcmp(val,"QUIET") == 0) return "Min";
if ((strcmp(val,"1") == 0) || (strcmp(val,"2") == 0)) return "Normal";
if ((strcmp(val,"3") == 0) || (strcmp(val,"4") == 0)) return "Max";
if (strcmp(val,"AUTO") == 0) return "Auto";
return "Normal";
}
const char* modeHA2HP(const char* val) {
const char* mode;
if (strcmp(val,"HeatOn") == 0) mode = "HEAT";
if (strcmp(val,"CoolOn") == 0) mode = "COOL";
if (strcmp(val,"AutoChangeOver") == 0) mode = "AUTO";
return mode;
}
const char* modeHP2HA(const char* val) {
if (strcmp(val,"HEAT") == 0) return "HeatOn";
if (strcmp(val,"COOL") == 0) return "CoolOn";
if (strcmp(val,"AUTO") == 0) return "AutoChangeOver";
return "HeatOn";
}
void publish(heatpumpSettings currentSettings) {
bool power = hp.getPowerSettingBool();
send(msgPower.set(power));
send(msgSTemp.set((int)currentSettings.temperature));
send(msgFanSp.set(fanHP2HA(currentSettings.fan)));
send(msgMode.set(power ? modeHP2HA(currentSettings.mode) : "Off"));
send(msgVane.set(currentSettings.vane));
}
void publish(heatpumpStatus currentStatus) {
send(msgRTemp.set((int)currentStatus.roomTemperature));
send(msgStat.set(currentStatus.operating ? "YES" : "NO"));
}
void hpSettingsChanged() {
heatpumpSettings currentSettings = hp.getSettings();
publish(currentSettings);
}
void hpStatusChanged(heatpumpStatus currentStatus) {
publish(currentStatus);
}
void setup() {
lastTempSend = millis();
// Create the callbacks
hp.setSettingsChangedCallback(hpSettingsChanged);
hp.setStatusChangedCallback(hpStatusChanged);
hp.connect(&Serial); // connect to the heatpump
hp.sync(); // Update settings
}
void before() {
// Reset the board to activate the radio
pinMode(9, OUTPUT);
digitalWrite(9, LOW);
digitalWrite(9, HIGH);
delay(10);
digitalWrite(9, LOW);
delay(10);
}
void presentation() {
sendSketchInfo("Heatpump Control", "1.4");
present(CHILD_POWER, S_BINARY, "Power");
present(CHILD_HVAC, S_HVAC, "HVAC");
present(CHILD_VANE, S_INFO, "Vane Dir");
present(CHILD_STAT, S_INFO, "Operating");
}
void receive(const MyMessage &msg) {
switch(msg.sensor) {
case CHILD_HVAC:
switch(msg.type) {
case V_HVAC_FLOW_STATE: {
const char* data = msg.getString();
bool power;
if (strcmp(data,"Off") == 0) {
power = false;
hp.setPowerSetting(power);
} else {
power = true;
hp.setModeSetting(modeHA2HP(data));
hp.setPowerSetting(power);
}
break;
}
case V_HVAC_SETPOINT_HEAT: {
hp.setTemperature(msg.getInt());
break;
}
case V_HVAC_SPEED: {
hp.setFanSpeed(fanHA2HP(msg.getString()));
break;
}
}
break;
case CHILD_VANE:
hp.setVaneSetting(msg.getString());
break;
case CHILD_POWER: // ON or OFF
hp.setPowerSetting(msg.getBool());
break;
default : // do nothing!
break;
}
hp.update();
hpStatusChanged(hp.getStatus());
}
void loop() {
hp.sync();
if (millis() > (lastTempSend + SEND_ROOM_TEMP_INTERVAL_MS)) {
// only send the temperature every 60s
hpStatusChanged(hp.getStatus());
hpSettingsChanged();
lastTempSend = millis();
}
wait(1000);
}
Hi folks,
Just resurrected my home assistant setup after a hiatus (previous install was early HA from 2021), I had my heatpump working before. But with the newer version of HA I'm getting the following logged.
2022-07-12 09:54:18 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;255;0;0;17;2.3.2
2022-07-12 09:54:18 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 250 child 255
2022-07-12 09:54:18 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;255;0;0;17;2.3.2
2022-07-12 09:54:18 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 250 child 255
2022-07-12 09:54:18 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;255;3;0;6;0
2022-07-12 09:54:18 DEBUG (MainThread) [mysensors.gateway_mqtt] Publishing 250;255;3;0;6;M
2022-07-12 09:54:19 DEBUG (SyncWorker_5) [mysensors.persistence] Saving sensors to persistence file /config/mysensors_9efc8d723297a2c52c4ecf34999e35c7.json
2022-07-12 09:54:19 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;255;3;0;11;Heatpump Control
2022-07-12 09:54:19 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 250 child 255
2022-07-12 09:54:20 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;255;3;0;12;1.4
2022-07-12 09:54:20 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 250 child 255
2022-07-12 09:54:20 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;255;3;0;12;1.4
2022-07-12 09:54:20 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 250 child 255
2022-07-12 09:54:21 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;0;0;0;3;Power
2022-07-12 09:54:21 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 250 child 0
2022-07-12 09:54:21 DEBUG (MainThread) [mysensors.gateway_mqtt] Subscribing to: mygateway1-out/250/0/1/+/+, qos: 0
2022-07-12 09:54:21 DEBUG (MainThread) [mysensors.gateway_mqtt] Subscribing to: mygateway1-out/250/0/2/+/+, qos: 0
2022-07-12 09:54:21 DEBUG (MainThread) [mysensors.gateway_mqtt] Subscribing to: mygateway1-out/250/+/4/+/+, qos: 0
2022-07-12 09:54:21 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;0;0;0;3;Power
2022-07-12 09:54:21 WARNING (MainThread) [mysensors.sensor] child_id 0 already exists in children of node 250, cannot add child
2022-07-12 09:54:22 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;1;0;0;29;HVAC
2022-07-12 09:54:22 WARNING (MainThread) [mysensors] Invalid <Message data="250;1;0;0;29;HVAC">: Not valid message sub-type: 29 for object value @ data['sub_type']. Got 29
not a valid value for object value @ data['payload']. Got 'HVAC'
2022-07-12 09:54:22 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;1;0;0;29;HVAC
2022-07-12 09:54:22 WARNING (MainThread) [mysensors] Invalid <Message data="250;1;0;0;29;HVAC">: Not valid message sub-type: 29 for object value @ data['sub_type']. Got 29
not a valid value for object value @ data['payload']. Got 'HVAC'
2022-07-12 09:54:22 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;5;0;0;36;Vane Dir
2022-07-12 09:54:22 WARNING (MainThread) [mysensors] Invalid <Message data="250;5;0;0;36;Vane Dir">: Not valid message sub-type: 36 for object value @ data['sub_type']. Got 36
not a valid value for object value @ data['payload']. Got 'Vane Dir'
2022-07-12 09:54:22 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;6;0;0;36;Operating
2022-07-12 09:54:22 WARNING (MainThread) [mysensors] Invalid <Message data="250;6;0;0;36;Operating">: Not valid message sub-type: 36 for object value @ data['sub_type']. Got 36
not a valid value for object value @ data['payload']. Got 'Operating'
022-07-12 09:54:29 DEBUG (SyncWorker_5) [mysensors.persistence] Saving sensors to persistence file /config/mysensors_9efc8d723297a2c52c4ecf34999e35c7.json
2022-07-12 09:54:29 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;0;1;0;2;1
2022-07-12 09:54:29 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 250 child 0
2022-07-12 09:54:29 DEBUG (MainThread) [homeassistant.components.mysensors.helpers] Discovering platform switch with devIds: [('9efc8d723297a2c52c4ecf34999e35c7', 250, 0, 2)]
2022-07-12 09:54:29 INFO (MainThread) [homeassistant.components.mysensors] Adding new devices: [<Entity Power: off>]
2022-07-12 09:54:29 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Power: value_type 2, value = 1
2022-07-12 09:54:29 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new switch.mysensors entity: switch.power
2022-07-12 09:54:39 DEBUG (SyncWorker_6) [mysensors.persistence] Saving sensors to persistence file /config/mysensors_9efc8d723297a2c52c4ecf34999e35c7.json
I'm guessing my presentation is wonky, attached is my sketch
[0_1657580859486_ard_hvac.ino](Uploading 100%)
Hey @BearWithBeard
I'd not put in a version:
as I'd assumed it would default to most recent... those assumptions always get you!
Pretty much working now, many thanks!
Hi Folks,
I'm getting the following error during presentation: As you can see some of the children are being picked up correctly but some of them are not
2021-03-01 19:07:44 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;255;3;0;11;Heatpump Control
2021-03-01 19:07:44 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 250 child 255
2021-03-01 19:07:44 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;255;3;0;12;1.1
2021-03-01 19:07:44 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 250 child 255
2021-03-01 19:07:44 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: heatpump 2: value_type 0, value = 21
2021-03-01 19:07:44 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: heatpump 0: value_type 2, value = 0
2021-03-01 19:07:44 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;0;0;0;3;Power
2021-03-01 19:07:44 WARNING (MainThread) [mysensors.sensor] child_id 0 already exists in children of node 250, cannot add child
2021-03-01 19:07:44 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;1;0;0;29;Set Point Temp
2021-03-01 19:07:44 WARNING (MainThread) [mysensors] Invalid <Message data="250;1;0;0;29;Set Point Temp">: Not valid message sub-type: 29 for object value @ data['sub_type']. Got 29
2021-03-01 19:07:44 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;2;0;0;6;Room Temp
2021-03-01 19:07:44 WARNING (MainThread) [mysensors.sensor] child_id 2 already exists in children of node 250, cannot add child
2021-03-01 19:07:44 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;3;0;0;29;Fan Speed
2021-03-01 19:07:44 WARNING (MainThread) [mysensors] Invalid <Message data="250;3;0;0;29;Fan Speed">: Not valid message sub-type: 29 for object value @ data['sub_type']. Got 29
2021-03-01 19:07:44 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;4;0;0;29;Mode
2021-03-01 19:07:44 WARNING (MainThread) [mysensors] Invalid <Message data="250;4;0;0;29;Mode">: Not valid message sub-type: 29 for object value @ data['sub_type']. Got 29
2021-03-01 19:07:44 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;5;0;0;29;Vane Dir
2021-03-01 19:07:44 WARNING (MainThread) [mysensors] Invalid <Message data="250;5;0;0;29;Vane Dir">: Not valid message sub-type: 29 for object value @ data['sub_type']. Got 29
2021-03-01 19:07:44 DEBUG (MainThread) [mysensors.gateway_mqtt] Receiving 250;6;0;0;36;Operating
2021-03-01 19:07:44 WARNING (MainThread) [mysensors] Invalid <Message data="250;6;0;0;36;Operating">: Not valid message sub-type: 36 for object value @ data['sub_type']. Got 36
I've also run the example mqtt.py from pymysensors outside of home assistant to see if my heatpump sensor was generically sending rubbish. But that didn't throw out any errors.
So could this be a problem with the mysensors integration in home-assistant?
TIA
Steve
[0_1614579780203_ard_hvac.ino](Uploading 100%)
Hi folks,
I'm having a bit of an issue with re-building my esp8266 mqtt gateway using the make file from the makeEspArduino project.
What I'm seeing is an issue compiling the following:
/home/sf/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:103:1: error: 'EthernetServer' does not name a type
EthernetServer _ethernetServer(_ethernetGatewayPort);
^
/home/sf/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:118:8: error: 'EthernetClient' does not name a type
static EthernetClient client = EthernetClient();
From the looks of it the defines at the start of my sketch are not being passed down to the MySensors components As those types are defined a few lines above the ones with the error in an ifdef block.
Before I disappear down a rabbit hole, does anyone have any suggestions as to how I can address this error?
TIA
Steve
Hi can you add the kicad files for the latest rev pls?
Hi,
So as I see it I would need to use the hardware serial for the connection to the heatpump and then create a software serial for debug messages. So something like this:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
// Enable debug prints
#define MY_DEBUG
#define MY_DEBUGDEVICE mySerial
#define MY_BAUD_RATE 9600
So the next question is how to present the heatpump to the gateway. Would you create one child id and then define each type of sensor/metric or is there a one-to-one mapping:
#define CHILD_HVAC 0
MyMessage msgHvacStatu(CHILD_HVAC, V_STATUS); // Status: ON, OFF
MyMessage msgHvacSTemp(CHILD_HVAC, V_TEMP); // Set Temp
MyMessage msgHvacRTemp(CHILD_HVAC, V_TEMP); // Room Temp
MyMessage msgHvacFanSp(CHILD_HVAC, V_HVAC_SPEED); // Fan Speed
or
#define CHILD_HVAC_STATUS 0
#define CHILD_HVAC_STEMP 1
#define CHILD_HVAC_RTEMP 2
#define CHILD_HVAC_FANSP 3
MyMessage msgHvacStatu(CHILD_HVAC_STATUS, V_STATUS); // Status: ON, OFF
MyMessage msgHvacSTemp(CHILD_HVAC_STEMP, V_TEMP); // Set Temp
MyMessage msgHvacRTemp(CHILD_HVAC_RTEMP, V_TEMP); // Room Temp
MyMessage msgHvacFanSp(CHILD_HVAC_FANSP, V_HVAC_SPEED); // Fan Speed
Hi Folks,
just trying to figure out how to get started with controlling a heatpump via a serial connection. I've found this blog entry which is my starting point. At the moment I'm unsure if I can connect the hardware serial of a pro mini to the heat pump and be able to debug it. Or would this require the use of a software serial port, or even springing for a board with more than one serial
Any pointers in the correct direction appreciated
sfozz
https://nicegear.nz/blog/hacking-a-mitsubishi-heat-pump-air-conditioner/