Homematic automation rules

Hi all,
I have a problem with configuration automation rules for my need. I have a couple of eq-3 MAX! radiator thermostats and my house is heated by gas-heater that I need to switch - that is simple. Thermostats are connected to raspberry with homegear and auto-detected by homematic component. I see them readings in dashboard.
What I want to create is rule where if any thermostat reads temperature lower than it’s target, it will switch my heater.
I created bash switch in configuration.yaml, and the part where I failed is reading temperatures from thermostats and comparing them. Documentation of climate component has many set_xxx functions but no gets.
Here is a screenshot of what I achieved by this moment https://scr.hu/vL92r3 - switch is working, automation doesn’t parse.
I would be grateful for any suggestions.

I think what you need is a sensor for your thermostats. Are there any sensors?

~Cheers

My thermostats have built-in sensors that I see in dashboard.

The reason why one of them shows 0 is because this item is not attached to radiator yet and not fully initialized. But as you see, the second one is reporting it’s temperature. I just need help manage how to read it in script together with target temperature and set an action if current temp is below target.

As I don’t have the component myself I have no way of knowing or testing myself. So could you go to the dev tools (navigationbar to the left on the bottom, second icon “<>”) for me and search for your entity_id you use to display here? On the right side you can see available attributes on this. Maybe this helps you?

~Cheers

I think you want the numeric state trigger. You can use a template with that to query the temp of your termostat.

The correct template for the current temperature would be:
{{ states.climate.meq123456.attributes.temperature }}

Thank you all for suggestions. I need to try with @danielperna84 template.
In the meantime I looked what properties my thermostats have:

Ok, I think that I am almost there.
I have sensor that gives me target temperature of thermostat and it’s working. I have working automation rules that reads current temperature and compare it to another value. The problem is how to insert my virtual sensor reading into below value?

sensor test:

  • platform: template
    sensors:
    main:
    value_template: ‘{{ states.climate.NEQ0611323.attributes.temperature }}’

automation:
trigger:
platform: numeric_state
entity_id: climate.NEQ0611323
value_template: ‘{{ states.climate.NEQ0611323.attributes.current_temperature }}’
below: sensor.test
action:
service: homeassistant.turn_on
entity_id: switch.heater

“below” should be a number. Also, you may need to make sure that current_temperature is a float or int.

value_template: ‘{{ states.climate.NEQ0611323.attributes.current_temperature | float }}’

When posting YAML, use preformatted text, not blockquote.

I obviously don’t understand something. Tried below configurations:

####First option####
automation_1:
  trigger:
    platform: numeric_state
    entity_id: climate.NEQ0611323
    value_template: '{{ states.climate.NEQ0611323.attributes.current_temperature }}'
    below:
      entity_id: climate.NEQ0611323
      value_template: '{{ states.climate.NEQ0611323.attributes.temperature | float}}'
  action:
    service: homeassistant.turn_on
    entity_id: switch.heater

####Second option####
automation_2:
  trigger:
    platform: numeric_state
    entity_id: climate.NEQ0611323
    value_template: '{{ states.climate.NEQ0611323.attributes.current_temperature }}'
    below:'{{ states.climate.NEQ0611323.attributes.temperature | float}}'
  action:
    service: homeassistant.turn_on
    entity_id: switch.heater

#####Third option#####
sensor NEQ0611323_target:
  - platform: template
    sensors:
      main:
        value_template: '{{ states.climate.NEQ0611323.attributes.temperature | float }}'

automation_3:
  trigger:
    platform: numeric_state
    entity_id: climate.NEQ0611323
    value_template: '{{ states.climate.NEQ0611323.attributes.current_temperature }}'
    below: sensor.NEQ0611323_target
  action:
    service: homeassistant.turn_on
    entity_id: switch.heater

Every option gives me log entry like this:

17-03-03 21:05:23 ERROR (MainThread) [homeassistant.bootstrap] Invalid config for [automation]: expected float for dictionary value @ data[‘trigger’][0][‘below’]. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 88). Please check the docs at Automation - Home Assistant
17-03-03 21:05:23 ERROR (MainThread) [homeassistant.bootstrap] component automation failed to initialize

Like I said - “below” needs to be a number, I think. Like “40”. Not a template or an entity_id.

But it’s useless then. I can’t set below to specific value because I want it to depend on target temperature of thermostat. Is it really impossible to do this?

I think I almost got it

automation:
  trigger:
    platform: state
    entity_id: climate.NEQ0611323
  action:
    service_template: >
      {% if states.climate.NEQ0611323.attributes.current_temperature < states.climate.NEQ0611323.attributes.temperature %}
      homeassistant.turn_on
      {% elif states.climate.NEQ0611323.attributes.current_temperature >= states.climate.NEQ0611323.attributes.temperature %}
      homeassistant.turn_off
      {% endif %}
    entity_id:
      - switch.heater

The last one problem is that my switch witch is command_line type, is not toggling by ‘turn_on’ and ‘turn_off’ commands. It has defined command_on and command_off but I can’t use it like 'homeassistant.command_on".

Succes!
Finaly working solution. Thank you all for suggestions, it would be impossible for me to achieve it without your tips.
I will post my code below because I was personally little frustrated that there is no example of similar configuration in documentation.

switch heater:
  platform: command_line
  switches:
    heater_switch:
      command_on: "sh /home/homeassistant/heater.sh 1"
      command_off: "sh /home/homeassistant/heater.sh 0"
      friendly_name: Piec

automation:
  trigger:
    platform: state
    entity_id: climate.NEQ0611323
  action:
    service_template: >
      {% if states.climate.NEQ0611323.attributes.current_temperature < states.climate.NEQ0611323.attributes.temperature %}
      switch.turn_on
      {% elif states.climate.NEQ0611323.attributes.current_temperature >= states.climate.NEQ0611323.attributes.temperature %}
      switch.turn_off
      {% endif %}
    entity_id:
      - switch.heater_switch
3 Likes