Mysensors HVAC not showing up

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?

1 Like

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
1 Like

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.

Can I use just the temperature setpoint without fan speed etc? Just got this in mysensors.json:

    "131": {
        "sensor_id": 131,
        "children": {
            "1": {
                "id": 1,
                "type": 29,
                "description": "Thermostat Biuro",
                "values": {
                    "45": "14.0",
                    "2": "0"
                }
            }

But there is no entity that corresponds to it. I was thinking this will make a thermostat faceplate anyway, but this is not the case.

@martinhjelmare could you tak a look at the problem I have described above? Many thanks in advance!

Well summer time. And aircons don’t work anymore. I can switch on|off. But for example speed control is not working anymore. Same for temp change. Temp change is even more interesting. Set it from lets say 18 to 20 and than it just reverts back. Seems a lot of changes have been done from last summer

Mysensors.json of node in question

    "41": {
        "sensor_id": 41,
        "children": {
            "0": {
                "id": 0,
                "type": 29,
                "description": "",
                "values": {
                    "0": "24.8",
                    "44": "18",
                    "21": "CoolOn",
                    "22": "Max"
                }
            },
            "2": {
                "id": 2,
                "type": 7,
                "description": "",
                "values": {
                    "1": "43.1",
                    "0": "1102525219"
                }
            },
            "3": {
                "id": 3,
                "type": 6,
                "description": "",
                "values": {
                    "0": "24.8",
                    "32": "25.3",
                    "4": "16.100"
                }
            },
            "4": {
                "id": 4,
                "type": 22,
                "description": "",
                "values": {
                    "45": "87.0",
                    "37": "269.0"
                }
            },
            "5": {
                "id": 5,
                "type": 24,
                "description": "",
                "values": {
                    "45": "00A0604702",
                    "37": "160.62"
                }
            },
            "136": {
                "id": 136,
                "type": 8,
                "description": "",
                "values": {}
            },
            "110": {
                "id": 110,
                "type": 7,
                "description": "",
                "values": {}
            },
            "16": {
                "id": 16,
                "type": 0,
                "description": "",
                "values": {}
            },
            "218": {
                "id": 218,
                "type": 1,
                "description": "",
                "values": {}
            },
            "164": {
                "id": 164,
                "type": 32,
                "description": "",
                "values": {}
            },
            "148": {
                "id": 148,
                "type": 38,
                "description": "",
                "values": {}
            },
            "254": {
                "id": 254,
                "type": 19,
                "description": "",
                "values": {}
            },
            "85": {
                "id": 85,
                "type": 4,
                "description": "45470FE7F8",
                "values": {}
            }
        },
        "type": 7,
        "sketch_name": "MYS Zal",
        "sketch_version": "2.1",
        "battery_level": 0,
        "protocol_version": "1.4",
        "heartbeat": 0
    },