Am I barking up the wrong tree trying to create a DIY heating controller like this?

I’m looking to setup a form of Heating Automation running in Home Assistant.

I run Home assistant on a Raspberry Pi 3 and all seems to be fine with what I have so far (Lights / Media Players etc)

My plan was to use Aqara Temperature / Humidity Sensors along with an LC Technology 4ch Relay board. Then with some automation, set some simple rules that allow the heating to go on/off at certain times / temperatures. I would also want to override the ‘timer’ and switch on/off when I want. As an added bonus, I would like to be able to easily adjust the set temperature whenever I wanted.

My question is, is the hardware I have chosen suitable for setting this up?

I am still working on getting the LC Tech relay to work, but I have set up an Aqara Sensor already. This is working fine via a Conbee Hub (DeConz add on) although doesn’t yet have any automation assigned to it. But my concern came when trying to set-up a simple Thermostat Card in Lovelace. Each time I try to set it up I get this message;

‘Specify an entity from within the climate domain.’

The Config is as follows;

 - badges: []
    cards:
      - entity: light.front_lights
        name: Front Lights
        type: light
      - entity: media_player.googlehome4501
        type: media-control
      - entity: sensor.living_room_temperature_3
        name: Living Room Thermostat
        type: thermostat
        elements: 
            - type: custom:thrmostat-card
              entity: sensor.living_room_temperature_3
              style:
                left: 63%
                top: 89%
                width: 15%
              ambient_temperature: sensor.average_living_room_temperature_3
              highlight_tap: true
              no_card: true
    title: Test

This has me wondering whether the Aqara Sensor is suitable?
Any advice is appreciated!

Not for that Lovelace card. It requires an entity in the climate domain (i.e. a thermostat).

The good news is you can create one using your temperature sensor and switch using this:

Hi tom_I

Thanks for the quick response! I did come across this when trying to get this working, but never managed to get it to show up. I suspect I’m missing something in the lovelace set up.

I have added the generic Thermostat to my config.yaml file

climate:
  - platform: generic_thermostat
    name: Living Room
    heater: light.front_lights
    target_sensor: sensor.living_room_temperature_3

Note; I’ve added a light entity (Sonoff) as a heater switch just now as I haven’t got the switch (relay) working yet. Not sure if this has any impact?

But not sure how you add this to the lovelace code?

cards:
      - entity: light.front_lights
        name: Front Lights
        type: light
      - entity: media_player.googlehome4501
        type: media-control
      - entity: sensor.average_living_room_temperature_3
        name: Living Room Thermostat
        type: thermostat
    title: Test

What should the entity be? I’ve also tried climate.generic_thermostat but to no avail
Thanks again

Couple of things.
I’m pretty sure that the heater needs to be in the switch domain.
How is this title compliant with the sticky at the top of the forum and how is anyone searching for solutions to a heating problem know to look at this.?
When you say config.yaml I assume you mean configuration.yaml ?
Not sure how you edit your files but in the same way you added the generic thermostat to the configuration.yaml but this time you insert the ‘card’ into your ui-lovelace.yaml.
Your card is slightly off in syntax too, check the docs as you haven’t specified a card type. (I see it at the bottom, so it must be an “editor” )

Hi Mutt,

Point taken re the Title. I’ll remember in future to make it more relevent.

I edit the yaml files in the configurator Add On. As you can see in the cards example above, I tried adding the Thermostat but to no avail. I also tried changing the type to generic_thermostat but got this message;

Unknown card type encountered: generic_thermostat.

image

I’m obviously missing something in the Lovelace Yaml file, but not sure what?

fixed it…

finity - Cheers ! :beer:

@Ydraiggoch, Sorry I’m not sure what you mean, you keep mixing up terms and they are not all going in the same direction.

You are aware that when you go to full yaml mode for lovelace then ALL your interface configuration is stored in these files ? ( I assume you do because that’s how you are refering to them)

BUT, that is JUST the UI, it doesn’t control anything. It merely displays it.
The ‘other’ YAML is everything in your configuation.yaml (not config.yaml) AND everything that’s referenced from that. eg automation.yaml for any automations that are dependent upon an entity chaging state etc. then there’s scripts.yaml for any sequence of events you don’t want to keep repeating or when you use a service template to do this OR do that. Then there are any entities you create in sensors.yaml, input_boolean.yaml etc. OR if you use ‘packages’ then you can mix and match.

The generic_thermostat goes in the configuration.yaml or an included file of some form.
See : - https://www.home-assistant.io/integrations/generic_thermostat/ as Tom advised.
It does NOT go in a lovelace yaml ‘card’
You THEN put (the output of this configured thermostat into) the thermostat in the ‘card’ (I’m not sure I’m making this clearer ! :crazy_face: )

Sorry if I’ve got the wrong end of the stick but I find your posts a bit confusing.

Hi Mutt,

Apologies, I don’t mean to make the posts confusing, so thanks for being patient with me! It’s probably just me using incorrect terminology, I am still learning (as I’m sure you’ve guessed!)

Anyway, your post makes perfect sense and I understand the difference between the various Yaml files.

All I am trying to do is get a Thermostat to show up in one of the overview screens.

I have this entry in configuration.yaml as per Tom’s advice;

climate:
  - platform: generic_thermostat
    name: Living Room
    heater: light.front_lights
    target_sensor: sensor.living_room_temperature_3

I appreciate that I probably need a switch entity for the heater, but at the moment don’t have one setup.

In my UI-lovelace.yaml file I have this;

  - badges: []
    cards:
      - entity: light.front_lights
        name: Front Lights
        type: light
      - entity: media_player.googlehome4501
        type: media-control
      - entity: sensor.living_room_temperature_3
        name: Living Room Thermostat
        type: generic_thermostat
    title: Test

The Front Light and the Media Player are visible and work fine, but I cannot get the Thermostat to show up. I just see the error message;

image

Could the problem be the fact I don’t have a ‘Switch’ entity specified in the ‘Heater’ entry in the configuration.yaml?

Once again, apologies if i’m causing confusion! And thanks to finity for sorting the title!

Ok, I think I have solved the problem.

I removed the lovelace yaml function in my configuration.yaml file so that Home assistant could do the entry for me. Once this was removed, I added a new thermostat card and it appeared. Also, just for information, it turns out that having the Light entity in the heater line does not make any difference. Home Assistant treats this as a switch and so when the desired temperature is not met, the ‘heating’ goes on but in this case the light goes on instead! :slight_smile:

Thanks for all your patience!

Then create a fake switch that you can then use to switch your lamp. look at : -

Here’s one I use to help switch any anciliary fans I care to use

switch:
  ## target (fake) switch for cooling
  - platform: template
    switches:
      cooling_switch:
        friendly_name: Cooling Switch
        value_template: "{{ is_state('input_boolean.ib_cool_cooling_switch', 'on') }}"
        turn_on:
          service: input_boolean.turn_on
          data:
            entity_id: input_boolean.ib_cool_cooling_switch
        turn_off:
          service: input_boolean.turn_off
          data:
            entity_id: input_boolean.ib_cool_cooling_switch
        icon_template: "{{ 'mdi:snowflake' if is_state('input_boolean.ib_cool_cooling_switch', 'on') else 'mdi:fan' }}"

I see you have managed to get it working with light instead, good job !

Can you post your full thermostat config ?

This is mine : -

climate:
  ## Heating
  - platform: generic_thermostat
    name: House Heat
    heater: switch.boiler_switch
    target_sensor: sensor.thermostat_heat_temperature
    min_temp: 6
    max_temp: 24
    ac_mode: false
    # target_temp: 19
    cold_tolerance: 0.2
    hot_tolerance: 0.2
    min_cycle_duration:
      seconds: 20
    initial_hvac_mode: "heat"
    precision: 0.1

Hi Mutt,

I don’t have a full config yet. I was going to work on that once I get my switches (4 Ch LC Technology) working.

But thanks for posting yours, that might be handy! :slight_smile: :grin:

I have done this type of thing other days.

For the climate part, in configuration.yaml

########## BEDROOM climate ###################
climate bedroom:
  - platform: generic_thermostat
    name: Bedroom
    heater: switch.actuator1
    target_sensor: sensor.bedroom_temp
    min_temp: 19
    max_temp: 24
    ac_mode: false
    target_temp: 22
    cold_tolerance: 0.2
    hot_tolerance: 0.0
    min_cycle_duration:
      seconds: 5
    keep_alive:
      minutes: 3
    initial_hvac_mode: "heat"
    precision: 0.1

where “sensor.bedroom_temp” is a Aqara sensor

and

“switch.actuator1” is a relay controlled by a ESP8266 board.

This relay controls a Thermal actuator on my floor heating distributor.

I have another relay controlled by an ESP module that ON/OFF boiler as soon as an actuator is ON (I have 6 heating zones in total)

Automation for boiler to turn OFF

- id: '1574707492769'
  alias: BOILER OFF
  description: ''
  trigger:
  - entity_id: switch.actuator1
    from: 'on'
    platform: state
    to: 'off'
  - entity_id: switch.actuator2
    from: 'on'
    platform: state
    to: 'off'
  - entity_id: switch.actuator3
    from: 'on'
    platform: state
    to: 'off'
  - entity_id: switch.actuator4
    from: 'on'
    platform: state
    to: 'off'
  - entity_id: switch.actuator5
    from: 'on'
    platform: state
    to: 'off'
  - entity_id: switch.actuator6
    from: 'on'
    platform: state
    to: 'off'
  condition:
  - condition: state
    entity_id: switch.actuator1
    state: 'off'
  - condition: state
    entity_id: switch.actuator2
    state: 'off'
  - condition: state
    entity_id: switch.actuator3
    state: 'off'
  - condition: state
    entity_id: switch.actuator4
    state: 'off'
  - condition: state
    entity_id: switch.actuator5
    state: 'off'
  - condition: state
    entity_id: switch.actuator6
    state: 'off'
  action:
  - data:
      entity_id: switch.boiler
    service: homeassistant.turn_off
  - data:
      message: BOILER is OFF
    service: persistent_notification.create
  - data:
      message: BOILER is OFF
    service: telegram_bot.send_message

Automation for boiler to turn ON

- id: '1574707807706'
  alias: BOILER ON
  description: ''
  trigger:
  - entity_id: switch.actuator1
    from: 'off'
    platform: state
    to: 'on'
  - entity_id: switch.actuator2
    from: 'off'
    platform: state
    to: 'on'
  - entity_id: switch.actuator3
    from: 'off'
    platform: state
    to: 'on'
  - entity_id: switch.actuator4
    from: 'off'
    platform: state
    to: 'on'
  - entity_id: switch.actuator5
    from: 'off'
    platform: state
    to: 'on'
  - entity_id: switch.actuator6
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - delay: '245'
  - data:
      message: BOILER is ON
    service: persistent_notification.create
  - data:
      entity_id: switch.boiler
    service: homeassistant.turn_on
  - data:
      message: BOILER is ON
    service: telegram_bot.send_message

Edit: sorry this was my very first message on this board. And it looks it is still not OK :frowning:

Please edit your post in line with Tinkerers sticky at the top of the forum.
Post code in the </> (button) pre-formatted code section.
We can’t read this to comment and cutting/pasting would require major reformatting.

Dave, as the thread owner, you get notifications if anyone posts to it.
Nobody else does.
I saw that there was a new post and happened to look otherwise I wouldn’t have known.
If you need to alert someone, use the reply button in ‘their’ post.
Or tag them eg @Mutt, but use that very cautiously, most members are very busy and don’t like being needlessly tagged. - You may get blocked by a few.

Understood Mutt, Thanks. I’m always happy to learn, and appreciate people like yourself who give instruction.

Hi iladi4466

I’m not wanting to change the topic of this thread, but could you tell me what you flashed your ESP8266 with to get the relay control to work?

I’ve just flashed the ESP01 on a LC Technology 4ch relay with Tasmota.

https://www.aliexpress.com/i/32965886110.html

All seems to work fine in tasmota until I set the MQTT which is obviously required for Home Assistant integration. But once the MQTT is set, the relays don’t change state. Did you have similar issues?

Thanks

I used a separate ESP board and a separate relay board. ESP is connected to Hass.io via MQTT and flashed with Tasmota. No, I don’t have similar issues. Maybe you should check how you configured MQTT in Hass and Tasmota

Hi iladi4466,

I pretty much have the same thing. Its an ESP01 module that connects to the 4 relay board.

I managed to work out the problem. Its due to the Baud rate being set incorrectly. It was at 9600 but needs to be 115200. All good now!

Thanks