Auto heating control - not easy :)

I agree, 2 years running hassio with same EVO SD card, now on ssd but for performance not because I had issues with the SD.

Thanks for posting this. The zwave thermostat in my garage pooped out and I was thinking of dipping my big toe in the world of Tasmota or ESPHome to come up with a more homebrew (and much cheaper!) solution. You’ve posted a great starting point if I decide to go the MQTT route.

{%- set multiplier = 1 -%}
{%- if is_state('input_select.' + area + '_heatpump_mode', 'cool' ) -%}
  {%- set multiplier = -1 -%}
{%- elif is_state('input_select.' + area + '_heatpump_mode', 'off') -%}
  {%- set multiplier = 0 -%}
{%- endif -%}
{{ (diff * multiplier) | round(1) }}

This was a clever. I wouldn’t have thought to do it this way. I’d have probably just done something with an absolute value filter but 6 & 1/2 dozen. It’s interesting to see how different people skin their cats. I am going to take note of this technique it could be useful one day.

{%- set diff = -1.234 -%}
{% set state = 'cool'%}
{%- set multiplier = 1 -%}
{%- if state == 'cool' -%}
  {%- set multiplier = -1 -%}
{%- elif state == 'off' -%}
  {%- set multiplier = 0 -%}
{%- endif -%}
{{ (diff * multiplier) | round(1) }}

{%- set diff = -1.234 -%}
{% set state = 'cool'%}
{%- if state == 'off' -%}
  {%- set diff = 0 -%}
{%- else -%}
   {%- set diff = diff | abs | round(1) -%}
{%- endif %}  
{{ diff }}

I also really like your timer solution. I’ve always just tried to use a delay or wait_template in situations like this but if the script gets called more than twice it starts to fall apart because of the underlying issues with automation/script behaviour when called again while still running. I have at least one place in my configuration (ironically my climate control) where something like this will be a better solution even if it means a couple second delay every time it runs.

      - wait_template: "{{ is_state('script.livingroom_climate_stat', 'off') }}"
        timeout: '00:00:15'
        continue_on_timeout: false

      - service: script.livingroom_climate_stat

I do have one question though. I don’t understand why you’re checking the from_state of input_text.livingroom_heatpump_command for invalid values in the livingroom_heatpump_status_changed automation. Why does it matter what the from_state was? Should’t you check the to_state for invalid values since that is the next command that will be sent to the heat pump? What did I miss here?

The reason for this would be easy to miss. When you initially start HA, before the input fields get re-populated with their previous values, their states are undefined. Without a condition for the from state, my heat pumps got a command sent to them every time I restarted HA.

1 Like

Ah ha. I see the light! I have some automations I have to delay turning on at reboot until the sensors involved get their states sorted out or weird things happen. Thanks again - I’m sure that all took a while to get that all figured out and put together.

If, for example, a State Trigger is used without a to: or from: then it will trigger for any change in the entity’s state or its attributes. A state-change can include changing from undefined to a “valid” state (like on or off) or vice-versa. You can also have the situation where to_state is identical to from_state. This can indicate there was no change to the entity’s state but there was a change in one of its attributes.

Knowing that the State Trigger can be triggered for a whole lot more reasons that just the entity’s state flipping from on to off, it may be necessary to filter out all these possibilities, using a condition, to prevent running an action when it shouldn’t.

I learned all this from pnbruckner after challenging him for using, what I called, ‘belt and suspenders’ conditions (they appeared to be overkill). Then he explained why and it all made sense.

OH kill me, kill me! Hass.io PROBLEM (no possibility to boot from USB with hassOS). Installation from Raspbian - PROBLEM with latest version https://github.com/home-assistant/home-assistant/issues/28361

2 days and hass still not running :slight_smile:

Same EVO card here, and also trying to get better responses.
Also, this config would be much simpler with NodeRed… I´m just starting to dip my toes in these waters though.

As I went through the same path as you are trying to go, I strongly advice you to use NodeRED for such automations. Also, to increase stability, control thermostats / actuators directly from NodeRED, if possible. Use HASS only for data preview or setting thermostat target temperatures.

In my experience, I had to implement “emergency mode” for my heating setup, because things happen to fail from time to time - from temperature sensors, to HASS and NodeRED connection failure or connection caching (actuators / temperature states were changed, but NodeRED saw old values). Eliminate as much failure points as possible. The point is, you want to be your heating automation as independent as it can be. Trust me :slight_smile:

For example, I had my router crashed one night and some temperature sensors was not updated, so system thought that some rooms are too cold. I woke up in sauna. Also I was very surprised when I found out how unstable are my Xiaomi BLE Temperature sensors due to BT connection instability. After few failures, I’ve started to turn heating system down if mandatory data becomes too old or unavailable.

If you’re interested, you can read about my heating setup:
https://community.home-assistant.io/t/my-approach-to-smart-heating-radiators-floor-heating-gas-boiler

So interesting @algirdasc - will study your project. Thanks for Node Red idea… Maybe Node Red should run on the same Raspberry beside hassbian?

Yes, it should, otherwise your heating will depend on switches / routers.

I’m currently running NodeRED natively and dockerized HASS on the same machine (Odroid XU4, Raspberry-like single board), but I’m planning on moving switches / sensors to NodeRED. Just to eliminate HASS / Docker failure scenarios :slight_smile:

Docker on raspbian is my next Step. After 2 days (hassio - failure, can´t boot from usb, raspbian - bad script for ha installation, I ´m now on hassbian with this problem SOLVED HASS not starting after clean hassbian (latest) install on Rapsi3 model B

Seems like I found the time when all ways of installing HASS are buggy :slight_smile:
So next try is raspbian+docker+hass.io - this is your way?

I’ve never had issues with raspbian + docker + home-assistant install (haven’t tried hass.io / hasbian, though).

Jason and I have discussed this offline.
We are both concerned about trusting HA to run a heating system (I’m very much in favour of Teras’s views on this) I have a fallback position should HA go down, admittedly not as efficient but will stop us freezing.
Jiran is obviously quite content with his backup solution, which makes me more sanguine about this approach.
I can’t help but feel that a ‘native’ HA solution will be the most reliable and that is the route I’ll take.
If Jiran wishes to persue another route that is completely up to him, he may even just wish to migrate at a later date.
I won’t have his entities so the best I can do is used copies of my tested code and do a config check. It will be written in a package so should be easy to implement as long as he matches the entity_id’s (mine to his or his to mine)
If anyone feels strongly to the contrary please feel free to step in.

@SteveDinn & Jason, Yeah, I used to have problems similar to this. But being one never afraid to steal a good idea, I follow Petro’s ethos on this and set binary sensors to define such switch states, so I don’t have to wait for the next time trigger or event to ensure everything is in the correct sequence slot.
The only other area where it has caused issues is; I have timers on all my lights, these must be triggered on an ‘off’ to ‘on’ as I also use different levels through the day which would otherwise reset the timers.

Now I wish to install HASS on raspi3. Seems I found the time gap in which all ways to install HASS are buggy. Right now, when I need it :frowning:

Go back to go, do not collect $200 (monopoly reference) :rofl:

Please open another topic for your issues about installing HASS on the Raspi3, this topic is about your heating control “issue”

Really? I thought the “Saga of Jiran” would become an international bestseller :rofl:
The number of people dropping by here just to see what other idea has popped into his head today :man_shrugging:

1 Like

I don’t have any time triggers, unless you count the 1 second timer that I use to wait before sending the command for my heart pump. Everything happens pretty much in real time.

That’s even better ! :+1: