Mysensors HVAC not showing up

Just tested the sketch. Mine didn’t compile due to the error on line

IRSender irSender(3);
     IRSender(uint8_t pin); // Cannot create generic IRSender instances
     ^
IR_TESTBED:32: error: within this context
 IRSender irSender(3);
                    ^

So i changed it back to IRSenderPWM irSender(3); as it seems this value is not used anywhere in the code. Compiled and uploaded to arduino (made changes to switch to fujitsu conditioner)

Still out of luck.
Stop HA. Remove the mysensors.json. Create it. Set it to HA conditions.
Then start HA an plug the sensor. In the MQTT logs

mys-out/31/255/0/0/17 2.1.1
mys-out/31/255/3/0/6 0
mys-in/31/255/3/0/6 M
mys-out/31/255/3/0/11 Heatpump
mys-out/31/255/3/0/12 2.1
mys-out/31/0/0/0/29 Thermostat
mys-out/31/0/1/0/44 20
mys-out/31/0/1/0/22 1
mys-out/31/0/1/0/21 1
mys-out/31/0/2/0/44 (null)
mys-in/31/0/1/0/44 20
mys-out/31/0/1/0/44 20
mys-out/31/0/2/0/22 (null)
mys-in/31/0/1/0/22 1
mys-out/31/0/1/0/22 1
mys-out/31/0/2/0/21 (null)
mys-in/31/0/1/0/21 1
mys-out/31/0/1/0/21 1

And nothing on the console of dmesg. So unplug and plug thesensor once again. All i can find in dmesg

[217533.277932] 2017-07-27T21:35:11.640481+03:00 home hass[16254]: #033[32m2017-07-27 21:35:11 INFO (Thread-13) [homeassistant.components.mysensors] Adding new devices: [<Entity Heatpump 31 0: unknown>]#033[0m
[217533.277963] 2017-07-27T21:35:11.640481+03:00 home hass[16254]: #033[32m2017-07-27 21:35:11 INFO (Thread-13) [homeassistant.components.mysensors] Adding new devices: [<Entity Heatpump 31 0: unknown>]#033[0m

And then in the HA log

2017-07-27 21:35:11 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 205, in async_update_ha_state
    "No entity id specified for entity {}".format(self.name))
homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity Heatpump 31 0

This is way beyond my understandign of HA and mysensors

The mqtt log looks good except for the values that are sent for types 21 and 22. You need to send eg Off for V_HVAC_FLOW_STATE and Auto for V_HVAC_SPEED. See the mysensors API for allowed values:

As for the error, that’s a bug, and I’m working on a fix for that. You should be able to workaround it by not sending messages too fast consecutively. You can try adding a wait of 200 ms between the send commands in the sketch.

If it’s still not working after those adjustments, please set logging to debug for mysensors in the logger component and capture a debug log after start of home assistant and after starting the HVAC node.

Edit: Regarding the compilation error, for my own interest, what version of the HeatpumpIR library are you using? I had to change the class name to make the sketch compile on my computer. Maybe I’m using a different version of the library?

The heatpump library is version=1.0.7 which is the latest available from ToniA github.
For the debugging will the homeassistant.components.mysensors: debug suffice? Or laso need to add the climate?

I’m a little bit lost with wait. There is already wait 2000 in the loop section for requesting of initial values. Add delay to sent values in function sendNewStateToGateway() ?
And for setting the values 21 and 22. Isn’t this already done in the function sendNewStateToGateway() ?

Do delay should look like below?

#define MY_RF24_CE_PIN 8

#define MY_RADIO_NRF24
#define MY_NODE_ID 31
#define CHILD_ID_HVAC 0

#include <MySensors.h>

// Change and uncomment only your heatpump model
#include <FujitsuHeatpumpIR.h>
//#include <PanasonicCKPHeatpumpIR.h>
//#include <PanasonicHeatpumpIR.h>
//#include <CarrierHeatpumpIR.h>
//#include <MideaHeatpumpIR.h>
//#include <MitsubishiHeatpumpIR.h>
//#include <SamsungHeatpumpIR.h>
//#include <SharpHeatpumpIR.h>
//#include <DaikinHeatpumpIR.h>

//Some global variables to hold the states
int POWER_STATE;
int TEMP_STATE = 20;
int FAN_STATE;
int MODE_STATE;
int VDIR_STATE;
int HDIR_STATE;
String HA_MODE_STATE = "Off";
String HA_FAN_STATE = "Auto";

IRSenderPWM irSender(3);  // IR led on Arduino digital pin 3, using Arduino PWM

//Change to your Heatpump
HeatpumpIR *heatpumpIR = new FujitsuHeatpumpIR();

/*
new PanasonicDKEHeatpumpIR()
new PanasonicJKEHeatpumpIR()
new PanasonicNKEHeatpumpIR()
new CarrierHeatpumpIR()
new MideaHeatpumpIR()
new FujitsuHeatpumpIR()
new MitsubishiFDHeatpumpIR()
new MitsubishiFEHeatpumpIR()
new SamsungHeatpumpIR()
new SharpHeatpumpIR()
new DaikinHeatpumpIR()
*/

bool initialValueSent = false;
bool initialValueSentArray[] = {false, false, false};

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);

void presentation() {
  sendSketchInfo("Heatpump", "2.1");
  present(CHILD_ID_HVAC, S_HVAC, "Thermostat");
}

void setup() {
}

void loop() {
  // put your main code here, to run repeatedly:
  if (!initialValueSent) {
    Serial.println("Sending initial value");
    sendNewStateToGateway();
    Serial.println("Requesting initial value from controller");
    request(CHILD_ID_HVAC, V_HVAC_SETPOINT_COOL);
    wait(2000, C_SET, V_HVAC_SETPOINT_COOL);
    request(CHILD_ID_HVAC, V_HVAC_SPEED);
    wait(2000, C_SET, V_HVAC_SPEED);
    request(CHILD_ID_HVAC, V_HVAC_FLOW_STATE);
    wait(2000, C_SET, V_HVAC_FLOW_STATE);
  }
}

void receive(const MyMessage &message) {
  if (message.isAck()) {
     Serial.println("This is an ack from gateway");
     return;
  }
  if (!initialValueSent) {
    Serial.println("Receiving initial value from controller");
  }

  Serial.print("Incoming message for: ");
  Serial.print(message.sensor);

  String recvData = message.data;
  recvData.trim();

  Serial.print(", New status: ");
  Serial.println(recvData);
  switch (message.type) {
    case V_HVAC_SPEED:
      Serial.println("V_HVAC_SPEED");
      if(recvData.equalsIgnoreCase("auto")) FAN_STATE = 0;
      else if(recvData.equalsIgnoreCase("min")) FAN_STATE = 1;
      else if(recvData.equalsIgnoreCase("normal")) FAN_STATE = 2;
      else if(recvData.equalsIgnoreCase("max")) FAN_STATE = 3;
      HA_FAN_STATE = recvData;
      initialValueSentArray[1] = true;
      sendFanStateToGateway();
    break;

    case V_HVAC_SETPOINT_COOL:
      Serial.println("V_HVAC_SETPOINT_COOL");
      TEMP_STATE = message.getFloat();
      Serial.println(TEMP_STATE);
      initialValueSentArray[0] = true;
      sendTempStateToGateway();
    break;

    case V_HVAC_FLOW_STATE:
      Serial.println("V_HVAC_FLOW_STATE");
      if (recvData.equalsIgnoreCase("coolon")) {
        POWER_STATE = 1;
        MODE_STATE = MODE_COOL;
      }
      else if (recvData.equalsIgnoreCase("heaton")) {
        POWER_STATE = 1;
        MODE_STATE = MODE_HEAT;
      }
      else if (recvData.equalsIgnoreCase("autochangeover")) {
        POWER_STATE = 1;
        MODE_STATE = MODE_AUTO;
      }
      else if (recvData.equalsIgnoreCase("off")){
        POWER_STATE = 0;
      }
      HA_MODE_STATE = recvData;
      initialValueSentArray[2] = true;
      sendModeStateToGateway();
      break;
  }
  for (int i = 0; i < 3; i++) {
    if (!initialValueSentArray[i]) {
      initialValueSent = false;
      break;
    }
    initialValueSent = true;
  }
  sendHeatpumpCommand();
}

void sendNewStateToGateway() {
  send(msgHVACSetPointC.set(TEMP_STATE));
  delay(200);
  send(msgHVACSpeed.set(HA_FAN_STATE));
  delay(200);
  send(msgHVACFlowState.set(HA_MODE_STATE));
  delay(200);
}

void sendTempStateToGateway() {
  send(msgHVACSetPointC.set(TEMP_STATE));
}

void sendFanStateToGateway() {
  send(msgHVACSpeed.set(HA_FAN_STATE));
}

void sendModeStateToGateway() {
  send(msgHVACFlowState.set(HA_MODE_STATE));
}

void sendHeatpumpCommand() {
  Serial.println("Power = " + (String)POWER_STATE);
  Serial.println("Mode = " + (String)MODE_STATE);
  Serial.println("Fan = " + (String)FAN_STATE);
  Serial.println("Temp = " + (String)TEMP_STATE);

  heatpumpIR->send(
    irSender, POWER_STATE, MODE_STATE, FAN_STATE, TEMP_STATE, VDIR_AUTO,
    HDIR_AUTO);
}
1 Like

EDIT: See UPDATED logger config below.

Use this logger config:

logger:
  default: warning
  logs:
    homeassistant.components.mqtt: debug
    homeassistant.components.mysensors: debug
    homeassistant.components.climate.mysensors: debug
    mysensors: debug

wait can take different number of arguments when calling it. The simplest form is just eg wait(200) to suspend local execution for 200 milliseconds and during this time process incoming messages. The more complex form with three arguments used in the loop function will stop waiting if a message of the specified type comes in before the time to wait is up.

So just replace the delay calls with wait at the places you have added them. We don’t want to use delay cause that doesn’t process messages in the background. Generally never use delay in mysensors sketches. Either use wait or sleep depending on if you have a battery powered device or not and/or need to process messages or not.

Regarding the initial values for V_HVAC_FLOW_STATE and V_HVAC_SPEED not being correct, it might have to do with
HA_MODE_STATE and HA_FAN_STATE being of String type instead of character arrays. You could try changing that when initializing them. I’m not at a computer right now, so I can’t test this myself. I’ll be able to within a couple of days probably.

1 Like

Ok. Made the folloing adjustments to the sketch. Changed to wait (200) instead of delay.
Changed declarations

String HA_MODE_STATE = “Off”;
String HA_FAN_STATE = “Auto”;

From capitalized as it is down in the script so it became

String HA_MODE_STATE = “off”;
String HA_FAN_STATE = “auto”;

This is MQTT ouput from start up of sensor

mys-out/31/255/0/0/17 2.1.1
mys-out/31/255/3/0/6 0
mys-in/31/255/3/0/6 M
mys-out/31/255/3/0/11 Heatpump
mys-out/31/255/3/0/12 2.1
mys-out/31/0/0/0/29 Thermostat
mys-out/31/0/1/0/44 20
mys-out/31/0/1/0/22 1
mys-out/31/0/1/0/21 1
mys-out/31/0/2/0/44 (null)
mys-out/31/0/2/0/22 (null)
mys-in/31/0/1/0/22 1
mys-out/31/0/1/0/22 1
mys-out/31/0/2/0/21 (null)
mys-in/31/0/1/0/21 1
mys-out/31/0/1/0/21 1
mys-out/31/0/1/0/44 20
mys-out/31/0/1/0/22 1
mys-out/31/0/1/0/21 1
mys-out/31/0/2/0/44 (null)
mys-in/31/0/1/0/44 20
mys-out/31/0/1/0/44 20
mys-out/31/0/2/0/22 (null)
mys-in/31/0/1/0/22 1
mys-out/31/0/1/0/22 1
mys-out/31/0/2/0/21 (null)
mys-in/31/0/1/0/21 1

Than in the newly created mysensors.json i got this
{"31": {"_battery_level": 0, "protocol_version": "2.1.1", "children": {"0": {"id": 0, "type": 29, "values": {"44": "20", "21": "1", "22": "1"}, "description": "Thermostat"}}, "sensor_id": 31, "sketch_name": "Heatpump", "type": 17, "sketch_version": "2.1"}}

And in the HA logs

2017-07-28 10:32:45 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 255 sub_type 17
2017-07-28 10:32:45 DEBUG (Thread-13) [homeassistant.components.mysensors] No sketch_name: node 31
2017-07-28 10:32:45 DEBUG (Thread-13) [homeassistant.components.mysensors] No sketch_name: node 31
2017-07-28 10:32:45 DEBUG (Thread-13) [homeassistant.components.mysensors] No sketch_name: node 31
2017-07-28 10:32:45 DEBUG (Thread-13) [homeassistant.components.mysensors] No sketch_name: node 31
2017-07-28 10:32:45 DEBUG (Thread-13) [homeassistant.components.mysensors] No sketch_name: node 31
2017-07-28 10:32:45 DEBUG (Thread-13) [homeassistant.components.mysensors] No sketch_name: node 31
2017-07-28 10:32:45 DEBUG (Thread-13) [homeassistant.components.mysensors] No sketch_name: node 31
2017-07-28 10:32:45 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 255 sub_type 11
2017-07-28 10:32:45 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 255 sub_type 12
2017-07-28 10:32:45 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 29
2017-07-28 10:32:45 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 22
2017-07-28 10:32:45 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 21
2017-07-28 10:32:45 INFO (Thread-13) [homeassistant.components.mysensors] Adding new devices: [<Entity Heatpump 31 0: unknown>]
2017-07-28 10:32:45 DEBUG (Thread-3) [homeassistant.components.climate.mysensors] Heatpump 31 0: value_type 21, value = 1
2017-07-28 10:32:45 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 381, in async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 212, in async_add_entity
    yield from self.hass.async_add_job(entity.update)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/climate/mysensors.py", line 183, in update
    self._values[value_type] = DICT_MYS_TO_HA[value]
KeyError: '1'
2017-07-28 10:32:47 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 22
2017-07-28 10:32:47 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 205, in async_update_ha_state
    "No entity id specified for entity {}".format(self.name))
homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity Heatpump 31 0
2017-07-28 10:32:48 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 21
2017-07-28 10:32:48 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 44
2017-07-28 10:32:48 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 205, in async_update_ha_state
    "No entity id specified for entity {}".format(self.name))
homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity Heatpump 31 0
2017-07-28 10:32:48 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 205, in async_update_ha_state
    "No entity id specified for entity {}".format(self.name))
homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity Heatpump 31 0
2017-07-28 10:32:48 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 22
2017-07-28 10:32:48 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 205, in async_update_ha_state
    "No entity id specified for entity {}".format(self.name))
homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity Heatpump 31 0
2017-07-28 10:32:48 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 21
2017-07-28 10:32:48 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 205, in async_update_ha_state
    "No entity id specified for entity {}".format(self.name))
homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity Heatpump 31 0
2017-07-28 10:32:48 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 44
2017-07-28 10:32:48 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 205, in async_update_ha_state
    "No entity id specified for entity {}".format(self.name))
homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity Heatpump 31 0
2017-07-28 10:32:48 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 22
2017-07-28 10:32:48 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 205, in async_update_ha_state
    "No entity id specified for entity {}".format(self.name))
homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity Heatpump 31 0

No climate component showed up. So shall i change string to char array? Will look it up on the internet

The values should be capitalized, don’t change that. You can experiment with the time you’re waiting after each send call. Try something crazy long like 1000 ms, to just see if the NoEntitySpecifiedError goes away. If that works you can go down in time until you get the error again.

Edit: But solve the initial value type thing first. You’ll get the KeyError otherwise and the entity will not be added due to that. And just to be clear, the values that are sent now are 1, but should be Off and Auto. I’m thinking they are converted to 1 due to a type mismatch.

Ok Done. Changed back to capitals.
Put wait (1000);
Fresh mysensors.json
And… Same…

2017-07-28 11:39:55 DEBUG (Thread-6) [mysensors.gateway_mqtt] Receiving 31;255;0;0;17;2.1.1
2017-07-28 11:39:55 DEBUG (Thread-5) [mysensors.gateway_mqtt] Receiving 31;255;3;0;6;0
2017-07-28 11:39:55 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 255 sub_type 17
2017-07-28 11:39:55 DEBUG (Thread-13) [homeassistant.components.mysensors] No sketch_name: node 31
2017-07-28 11:39:55 DEBUG (Thread-13) [homeassistant.components.mysensors] No sketch_name: node 31
2017-07-28 11:39:55 DEBUG (Thread-13) [homeassistant.components.mysensors] No sketch_name: node 31
2017-07-28 11:39:55 DEBUG (Thread-13) [homeassistant.components.mysensors] No sketch_name: node 31
2017-07-28 11:39:55 DEBUG (Thread-13) [homeassistant.components.mysensors] No sketch_name: node 31
2017-07-28 11:39:55 DEBUG (Thread-13) [homeassistant.components.mysensors] No sketch_name: node 31
2017-07-28 11:39:55 DEBUG (Thread-13) [homeassistant.components.mysensors] No sketch_name: node 31
2017-07-28 11:39:55 DEBUG (Thread-13) [mysensors.gateway_mqtt] Publishing 31;255;3;0;6;M

2017-07-28 11:39:56 DEBUG (Thread-10) [mysensors.gateway_mqtt] Receiving 31;255;3;0;11;Heatpump
2017-07-28 11:39:56 DEBUG (Thread-9) [mysensors.gateway_mqtt] Receiving 31;255;3;0;12;2.1
2017-07-28 11:39:56 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 255 sub_type 11
2017-07-28 11:39:56 DEBUG (Thread-4) [mysensors.gateway_mqtt] Receiving 31;0;0;0;29;Thermostat
2017-07-28 11:39:56 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 255 sub_type 12
2017-07-28 11:39:56 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 29
2017-07-28 11:39:56 DEBUG (Thread-13) [mysensors.gateway_mqtt] Subscribing to: mys-out/31/0/1/+/+
2017-07-28 11:39:56 DEBUG (Thread-13) [mysensors.gateway_mqtt] Subscribing to: mys-out/31/0/2/+/+
2017-07-28 11:39:56 DEBUG (Thread-13) [mysensors.gateway_mqtt] Subscribing to: mys-out/31/+/4/+/+
2017-07-28 11:39:57 DEBUG (Thread-6) [mysensors.gateway_mqtt] Receiving 31;0;1;0;22;1
2017-07-28 11:39:57 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 22
2017-07-28 11:39:58 DEBUG (Thread-5) [mysensors.gateway_mqtt] Receiving 31;0;1;0;21;1
2017-07-28 11:39:58 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 21
2017-07-28 11:39:58 INFO (Thread-13) [homeassistant.components.mysensors] Adding new devices: [<Entity Heatpump 31 0: unknown>]
2017-07-28 11:39:58 DEBUG (Thread-3) [homeassistant.components.climate.mysensors] Heatpump 31 0: value_type 21, value = 1
2017-07-28 11:39:58 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 381, in async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 212, in async_add_entity
    yield from self.hass.async_add_job(entity.update)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/climate/mysensors.py", line 183, in update
    self._values[value_type] = DICT_MYS_TO_HA[value]
KeyError: '1'
2017-07-28 11:40:00 DEBUG (Thread-10) [mysensors.gateway_mqtt] Receiving 31;0;2;0;44;
2017-07-28 11:40:02 DEBUG (Thread-7) [mysensors.gateway_mqtt] Receiving 31;0;2;0;22;
2017-07-28 11:40:02 DEBUG (Thread-13) [mysensors.gateway_mqtt] Publishing 31;0;1;0;22;1

2017-07-28 11:40:02 DEBUG (Thread-12) [mysensors.gateway_mqtt] Receiving 31;0;1;0;22;1
2017-07-28 11:40:02 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 22
2017-07-28 11:40:02 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 205, in async_update_ha_state
    "No entity id specified for entity {}".format(self.name))
homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity Heatpump 31 0
2017-07-28 11:40:02 DEBUG (Thread-6) [mysensors.gateway_mqtt] Receiving 31;0;2;0;21;
2017-07-28 11:40:02 DEBUG (Thread-13) [mysensors.gateway_mqtt] Publishing 31;0;1;0;21;1

2017-07-28 11:40:02 DEBUG (Thread-3) [mysensors.gateway_mqtt] Receiving 31;0;1;0;21;1
2017-07-28 11:40:02 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 21
2017-07-28 11:40:02 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 205, in async_update_ha_state
    "No entity id specified for entity {}".format(self.name))
homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity Heatpump 31 0
2017-07-28 11:40:02 DEBUG (Thread-1) [mysensors.gateway_mqtt] Receiving 31;0;1;0;44;20
2017-07-28 11:40:02 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 44
2017-07-28 11:40:02 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 205, in async_update_ha_state
    "No entity id specified for entity {}".format(self.name))
homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity Heatpump 31 0
2017-07-28 11:40:03 DEBUG (Thread-10) [mysensors.gateway_mqtt] Receiving 31;0;1;0;22;1
2017-07-28 11:40:03 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 22
2017-07-28 11:40:03 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 205, in async_update_ha_state
    "No entity id specified for entity {}".format(self.name))
homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity Heatpump 31 0
2017-07-28 11:40:04 DEBUG (Thread-4) [mysensors.gateway_mqtt] Receiving 31;0;1;0;21;1
2017-07-28 11:40:04 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 21
2017-07-28 11:40:04 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 205, in async_update_ha_state
    "No entity id specified for entity {}".format(self.name))
homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity Heatpump 31 0
2017-07-28 11:40:06 DEBUG (Thread-6) [mysensors.gateway_mqtt] Receiving 31;0;2;0;44;
2017-07-28 11:40:06 DEBUG (Thread-13) [mysensors.gateway_mqtt] Publishing 31;0;1;0;44;20

2017-07-28 11:40:06 DEBUG (Thread-3) [mysensors.gateway_mqtt] Receiving 31;0;1;0;44;20
2017-07-28 11:40:06 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 44
2017-07-28 11:40:06 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 205, in async_update_ha_state
    "No entity id specified for entity {}".format(self.name))
homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity Heatpump 31 0
2017-07-28 11:40:06 DEBUG (Thread-1) [mysensors.gateway_mqtt] Receiving 31;0;2;0;22;
2017-07-28 11:40:06 DEBUG (Thread-13) [mysensors.gateway_mqtt] Publishing 31;0;1;0;22;1

2017-07-28 11:40:06 DEBUG (Thread-9) [mysensors.gateway_mqtt] Receiving 31;0;1;0;22;1
2017-07-28 11:40:06 DEBUG (Thread-13) [homeassistant.components.mysensors] Update: node 31, child 0 sub_type 22
2017-07-28 11:40:06 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 205, in async_update_ha_state
    "No entity id specified for entity {}".format(self.name))
homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity Heatpump 31 0
2017-07-28 11:40:06 DEBUG (Thread-7) [mysensors.gateway_mqtt] Receiving 31;0;2;0;21;
2017-07-28 11:40:06 DEBUG (Thread-13) [mysensors.gateway_mqtt] Publishing 31;0;1;0;21;1

This i what the code looks like

/*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*/

#define MY_RF24_CE_PIN 8

#define MY_RADIO_NRF24
#define MY_NODE_ID 31
#define CHILD_ID_HVAC 0

#include <MySensors.h>

// Change and uncomment only your heatpump model
#include <FujitsuHeatpumpIR.h>
//#include <PanasonicCKPHeatpumpIR.h>
//#include <PanasonicHeatpumpIR.h>
//#include <CarrierHeatpumpIR.h>
//#include <MideaHeatpumpIR.h>
//#include <MitsubishiHeatpumpIR.h>
//#include <SamsungHeatpumpIR.h>
//#include <SharpHeatpumpIR.h>
//#include <DaikinHeatpumpIR.h>

//Some global variables to hold the states
int POWER_STATE;
int TEMP_STATE = 20;
int FAN_STATE;
int MODE_STATE;
int VDIR_STATE;
int HDIR_STATE;
String HA_MODE_STATE = "Off";
String HA_FAN_STATE = "Auto";

IRSenderPWM irSender(3);  // IR led on Arduino digital pin 3, using Arduino PWM

//Change to your Heatpump
HeatpumpIR *heatpumpIR = new FujitsuHeatpumpIR();

/*
new PanasonicDKEHeatpumpIR()
new PanasonicJKEHeatpumpIR()
new PanasonicNKEHeatpumpIR()
new CarrierHeatpumpIR()
new MideaHeatpumpIR()
new FujitsuHeatpumpIR()
new MitsubishiFDHeatpumpIR()
new MitsubishiFEHeatpumpIR()
new SamsungHeatpumpIR()
new SharpHeatpumpIR()
new DaikinHeatpumpIR()
*/

bool initialValueSent = false;
bool initialValueSentArray[] = {false, false, false};

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);

void presentation() {
  sendSketchInfo("Heatpump", "2.1");
  present(CHILD_ID_HVAC, S_HVAC, "Thermostat");
}

void setup() {
}

void loop() {
  // put your main code here, to run repeatedly:
  if (!initialValueSent) {
    Serial.println("Sending initial value");
    sendNewStateToGateway();
    wait (1000);
    Serial.println("Requesting initial value from controller");
    request(CHILD_ID_HVAC, V_HVAC_SETPOINT_COOL);
    wait(2000, C_SET, V_HVAC_SETPOINT_COOL);
    request(CHILD_ID_HVAC, V_HVAC_SPEED);
    wait(2000, C_SET, V_HVAC_SPEED);
    request(CHILD_ID_HVAC, V_HVAC_FLOW_STATE);
    wait(2000, C_SET, V_HVAC_FLOW_STATE);
  }
}

void receive(const MyMessage &message) {
  if (message.isAck()) {
     Serial.println("This is an ack from gateway");
     return;
  }
  if (!initialValueSent) {
    Serial.println("Receiving initial value from controller");
  }

  Serial.print("Incoming message for: ");
  Serial.print(message.sensor);

  String recvData = message.data;
  recvData.trim();

  Serial.print(", New status: ");
  Serial.println(recvData);
  switch (message.type) {
    case V_HVAC_SPEED:
      Serial.println("V_HVAC_SPEED");
      if(recvData.equalsIgnoreCase("auto")) FAN_STATE = 0;
      else if(recvData.equalsIgnoreCase("min")) FAN_STATE = 1;
      else if(recvData.equalsIgnoreCase("normal")) FAN_STATE = 2;
      else if(recvData.equalsIgnoreCase("max")) FAN_STATE = 3;
      HA_FAN_STATE = recvData;
      initialValueSentArray[1] = true;
      sendFanStateToGateway();
    break;

    case V_HVAC_SETPOINT_COOL:
      Serial.println("V_HVAC_SETPOINT_COOL");
      TEMP_STATE = message.getFloat();
      Serial.println(TEMP_STATE);
      initialValueSentArray[0] = true;
      sendTempStateToGateway();
    break;

    case V_HVAC_FLOW_STATE:
      Serial.println("V_HVAC_FLOW_STATE");
      if (recvData.equalsIgnoreCase("coolon")) {
        POWER_STATE = 1;
        MODE_STATE = MODE_COOL;
      }
      else if (recvData.equalsIgnoreCase("heaton")) {
        POWER_STATE = 1;
        MODE_STATE = MODE_HEAT;
      }
      else if (recvData.equalsIgnoreCase("autochangeover")) {
        POWER_STATE = 1;
        MODE_STATE = MODE_AUTO;
      }
      else if (recvData.equalsIgnoreCase("off")){
        POWER_STATE = 0;
      }
      HA_MODE_STATE = recvData;
      initialValueSentArray[2] = true;
      sendModeStateToGateway();
      break;
  }
  for (int i = 0; i < 3; i++) {
    if (!initialValueSentArray[i]) {
      initialValueSent = false;
      break;
    }
    initialValueSent = true;
  }
  sendHeatpumpCommand();
}

void sendNewStateToGateway() {
  send(msgHVACSetPointC.set(TEMP_STATE));
  wait (1000);
  send(msgHVACSpeed.set(HA_FAN_STATE));
  wait (1000);
  send(msgHVACFlowState.set(HA_MODE_STATE));
  wait (1000);
}

void sendTempStateToGateway() {
  send(msgHVACSetPointC.set(TEMP_STATE));
}

void sendFanStateToGateway() {
  send(msgHVACSpeed.set(HA_FAN_STATE));
}

void sendModeStateToGateway() {
  send(msgHVACFlowState.set(HA_MODE_STATE));
}

void sendHeatpumpCommand() {
  Serial.println("Power = " + (String)POWER_STATE);
  Serial.println("Mode = " + (String)MODE_STATE);
  Serial.println("Fan = " + (String)FAN_STATE);
  Serial.println("Temp = " + (String)TEMP_STATE);

  heatpumpIR->send(
    irSender, POWER_STATE, MODE_STATE, FAN_STATE, TEMP_STATE, VDIR_AUTO,
    HDIR_AUTO);
}

Yeah you have to solve the problem with the type of payload sent for V_HVAC_FLOW_STATE and V_HVAC_SPEED. You can look at the mysensors RGB light example sketch in the home assistant docs, how I sent character arrays in that sketch. You’ll probably need to do some conversion in the receive function too.

Hi guys,

I’ve been having the same issues and the sketch below solves it (it’s messy, but it’s a proof of concept):

/*
#define MODE_AUTO   1
#define MODE_HEAT   2
#define MODE_COOL   3
#define MODE_DRY    4
#define MODE_FAN    5
#define MODE_MAINT  6

#define FAN_AUTO    0
#define FAN_1       1
#define FAN_2       2
#define FAN_3       3
#define FAN_4       4
#define FAN_5       5

#define VDIR_AUTO   0
#define VDIR_MANUAL 0
#define VDIR_SWING  1
#define VDIR_UP     2
#define VDIR_MUP    3
#define VDIR_MIDDLE 4
#define VDIR_MDOWN  5
#define VDIR_DOWN   6

#define HDIR_AUTO   0
#define HDIR_MANUAL 0
#define HDIR_SWING  1
#define HDIR_MIDDLE 2
#define HDIR_LEFT   3
#define HDIR_MLEFT  4
#define HDIR_MRIGHT 5
#define HDIR_RIGHT  6
 
 */

// Enable debug prints to serial monitor
#define MY_DEBUG 

// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69

#define CHILD_ID_HVAC 3

#define MY_RF24_PA_LEVEL RF24_PA_MAX

// Enable repeater functionality for this node
#define MY_REPEATER_FEATURE

#include <MySensors.h>
#include <MideaHeatpumpIR.h>

//Some global variables to hold the states
int POWER_STATE;
int TEMP_STATE;
int FAN_STATE;
int MODE_STATE;
int VDIR_STATE;
int HDIR_STATE;
String HA_MODE_STATE = "Off";
String HA_FAN_STATE = "Min";

IRSenderPWM irSender(3);       // IR led on Arduino digital pin 3, using Arduino PWM

HeatpumpIR *heatpumpIR = new MideaHeatpumpIR();

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);

bool initialValueSent = false;

void before() {
  loadState(CHILD_ID_HVAC);
}

void setup()  
{
  Serial.begin(115200);
}

void presentation() {
  // Send the sketch version information to the gateway and Controller
  sendSketchInfo("MasterBedroomUnit", "2.0.3");
  
  Serial.println("Presenting sensor...");
  // Register all sensors to gw (they will be created as child devices)
  present(CHILD_ID_HVAC, S_HVAC, "");
}


void loop()
{
  if (!initialValueSent) {
    Serial.println("Sending initial values");
    POWER_STATE = 0;
    MODE_STATE = MODE_AUTO;
    FAN_STATE = 1;
    TEMP_STATE = 24;
    sendHeatpumpCommand();
    sendNewStateToGateway();
    
    request(CHILD_ID_HVAC, V_HVAC_SETPOINT_COOL);
    wait(3000, C_SET, V_HVAC_SETPOINT_COOL);
    request(CHILD_ID_HVAC, V_HVAC_SPEED);
    wait(3000, C_SET, V_HVAC_SPEED);
    request(CHILD_ID_HVAC, V_HVAC_FLOW_STATE);
    wait(3000, C_SET, V_HVAC_FLOW_STATE);
    //initialValueSent = true;
  }
}

void receive(const MyMessage &message) {
  if (message.isAck()) {
     Serial.println("This is an ack from gateway");
     //return;
  }

  Serial.print("Incoming message for: ");
  Serial.print(message.sensor);

  String recvData = message.data;
  recvData.trim();

  Serial.print(", New status: ");
  Serial.println(recvData);
  switch (message.type) {
    case V_HVAC_SPEED:
      Serial.println("V_HVAC_SPEED");

      if(recvData.equalsIgnoreCase("auto")) {
        FAN_STATE = 0;
        HA_FAN_STATE = "Auto";
      }
      else if(recvData.equalsIgnoreCase("min")) {
        FAN_STATE = 1;
        HA_FAN_STATE = "Min";
      }
      else if(recvData.equalsIgnoreCase("normal")) {
        FAN_STATE = 2;
        HA_FAN_STATE = "Normal";
      }
      else if(recvData.equalsIgnoreCase("max")) {
        FAN_STATE = 3;
        HA_FAN_STATE = "Max";
      }
    break;

    case V_HVAC_SETPOINT_COOL:
      Serial.println("V_HVAC_SETPOINT_COOL");
      TEMP_STATE = message.getFloat();
      Serial.println(TEMP_STATE);
    break;

    case V_HVAC_FLOW_STATE:
      Serial.println("V_HVAC_FLOW_STATE");
      if (recvData.equalsIgnoreCase("coolon")) {
        POWER_STATE = 1;
        MODE_STATE = MODE_COOL;
        HA_MODE_STATE = "CoolOn";
      }
      else if (recvData.equalsIgnoreCase("heaton")) {
        POWER_STATE = 1;
        MODE_STATE = MODE_HEAT;
        HA_MODE_STATE = "HeatOn";
      }
      else if (recvData.equalsIgnoreCase("autochangeover")) {
        POWER_STATE = 1;
        MODE_STATE = MODE_AUTO;
        HA_MODE_STATE = "AutoChangeOver";
      }
      else if (recvData.equalsIgnoreCase("off")){
        POWER_STATE = 0;
        HA_MODE_STATE = "Off";
      }
      initialValueSent = true;
      break;
  }
  sendHeatpumpCommand();
  sendNewStateToGateway();
}

void sendNewStateToGateway() {
  send(msgHVACSetPointC.set(TEMP_STATE));
  wait(1000, C_SET, V_HVAC_SETPOINT_COOL);
  char fan_state[HA_FAN_STATE.length() + 1];
  HA_FAN_STATE.toCharArray(fan_state, HA_FAN_STATE.length() + 1);
  send(msgHVACSpeed.set(fan_state));
  wait(1000, C_SET, V_HVAC_SPEED);
  char mode_state[HA_MODE_STATE.length() + 1];
  HA_MODE_STATE.toCharArray(mode_state, HA_MODE_STATE.length() + 1);
  send(msgHVACFlowState.set(mode_state));
  wait(1000, C_SET, V_HVAC_FLOW_STATE);
}

void sendHeatpumpCommand() {
  Serial.println("Power = " + (String)POWER_STATE);
  Serial.println("Mode = " + (String)MODE_STATE);
  Serial.println("Fan = " + (String)FAN_STATE);
  Serial.println("Temp = " + (String)TEMP_STATE);

  heatpumpIR->send(irSender, POWER_STATE, MODE_STATE, FAN_STATE, TEMP_STATE, VDIR_AUTO, HDIR_AUTO);
}
2 Likes

Wow! Where have you been before? It works. The only question is that in the climate component there is a graph for the current temp? To integrate DHT connected to my sensors - which topic shall it send to? Is it a standard V_TEMP like

MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); ???

Almost, you should use the same child id as for the HVAC.

MyMessage msgTemp(CHILD_ID_HVAC, V_TEMP);

Thank you. Sounds great. So i can supply the reading as a separate sensor and as a part of climate component.

1 Like

Yes, if you present another child as S_TEMP and report the V_TEMP for that child it will show as a separate sensor.

1 Like

Well after much struggle did get it together. Still a question remains - in the climate component the temperature is set in a 0.5 increment. While most airconds use only a 1C incriment. Is there any setting for this?

Yes, by setting target_temp_step for the entity_id in question under the customize key under homeassistant in your configuration.yaml.

homeassistant:
...
  customize:
    climate.test:
      target_temp_step: 1

Can you please add it to the docs? i’ve rechecked the customization documentation, climate component, mysensors component and seems couldn’t find it

If I get some time, yes, but the docs are very easy to update for even a novice githubber. Every page has an edit on github button. Just follow this guide:

This change should go to the climate component page and possibly the customize page.

Ok will do that. It’s just that it is only one of the parameters. Any others can be customized?

I’m glad I found this thread! I set up an ESP8266 MQTT gateway on the weekend and couldn’t work out how to get the HVAC control working.

I’ll work through the solutions presented here and will report back.

All entity state attributes can be customized, but some don’t make sense to customize cause they are just info for the user or part of the sensor report, and some are hidden by default so can be hard to find out about.