Map target temperature from generic climate component to service

Hi,

im searching for a solution to map the target temperature from the generic climate component to a service. I want to send the value to the modbus.write_register service.
Can someone help me out?

Thanks
Klaus

  - alias: 'Map Target Temp'
    initial_state: true
    trigger:
      platform: event
      event_type: climate.set_temperature
      event_data:
        entity_id: climate.arbeiten
    action:
      service: modbus.write_register
      data_template: 
          unit: 1
          address: 12295
          value: '{{ trigger.event }}'

I don’t know the exact syntax… But it’ll be something like trigger.event.data.temperature.

Look up “event trigger” as well as “climate service” in the home assistant docs.

Hi,

this works except of the value template in the action part.
How do I map the value attribute temperature?
Sorry. Just started with home assistant.

  - alias: 'Map Target Temp'
     initial_state: true
     trigger:
       platform: numeric_state
       entity_id: climate.arbeiten
       value_template: '{{ state.attributes.temperature }}'
       above: 17
       below: 30
     action:
       service_template: modbus.write_register
       data: 
           unit: 1
           address: 12295
       data_template:
           value: '{{ **trigger.to_state.attributes.temperature**}}'

Documentation and feature set can change rapidly, so I may be wrong. But I don’t think you can have a “data” and a “data_template”. Just use “data_template” for everything if you have any values that need template features.

Otherwise, nothing is standing out as being wrong to me. Give that a shot and if it doesn’t work, be sure to post any errors shown in the logs.

Thanks for your reply.

This works now

   - alias: 'Map Target Temp'
     initial_state: true
     trigger:
       platform: state
       entity_id: climate.arbeiten
     action:
       service_template: modbus.write_register
       data: 
           unit: 1
           address: 12295
       data_template:
           value: '{{ states.climate.arbeiten.attributes.temperature | int }}'
1 Like