Automation by increasing value of an attribute

Hi,

I am a newby at HA…

First of all, where can I find a good documentiation of YAML scripting of automation. Classes, methods, examples etc.

My current problem is that I want to start DHW pump when the heatpump starts making DHW (domestic heat water).
(Note: I have two tanks for DHW in series, the first is heated by the heatpump, the second is heated by gas boiler, that’s why I want to circulate the water between the two tanks.)

So the automation should be the following: when increasing the heat temperature of the tank (heated by the heatpump), dhw circulation pump should start (on).

heat pump’s entity id: water_heater. 146235046568379_water_heater
temperature of the water tank: water_heater.tank_actual_temperature attribute of this entity
looks like: tank_actual_temperature: 30

alias: DHW by Heatpump -> DHW circulation
description: DHW making
trigger:
  - platform: state
    entity_id:
      - water_heater.146235046568379_water_heater
    attribute: tank_actual_temperature
condition:
  - condition: template
    value_template: "{{ trigger.from_state.state|int(0) < trigger.to_state.state|int(0) }}"
action:
  - service: logbook.log
    data:
      name: DHW_temp_inc
      message: DHW temperature increasing
      entity_id: water_heater.146235046568379_water_heater
  - delay: 300
mode: single
max_exceeded: silent

So I think the trigger.from_state.state|int(0) is wrong, as the state of the heatpump is on/off. But how can I reference the tank_actual_temperature attribute to the condition?

Or is there other approach for my problem?

Thanks,
Tom

condition:
  - condition: template
    value_template: "{{ trigger.from_state.attributes.tank_actual_temperature|int(0) < trigger.to_state.attributes.tank_actual_temperature|int(0) }}"

Reference: State Objects

2 Likes

Many thanks Taras! This was a great help!

1 Like