Replacing the value with a sensor value

I’m trying to get the value of a sensor sensor.victronzon into the value of this YAML code below. The value is a float and rounded when viewed in the developers toolkit.

alias: Handelen met energie - Handmatig ontladen snel
description: ""
trigger:
  - platform: state
    entity_id:
      - input_button.handmatig_ontladen_snel
condition: []
action:
  - device_id: 99323af3cb25907d241ed33a162afcea
    domain: number
    entity_id: 53825fb0c8d4bc917b04789caaf17c77
    type: set_value
    value: -3500
mode: single

I tried with ChatGPT to convert this but I got error’s like: not a valid value for dictionary value @ data[‘entity_id’]. Got None

This is the code i use:

alias: Handelen met energie - Handmatig ontladen snel + zon
description: ""
trigger:
  - platform: state
    entity_id:
      - input_button.handmatig_ontladen_snel_zon
condition: []
action:
  - device_id: 99323af3cb25907d241ed33a162afcea
    domain: number
    entity_id: 53825fb0c8d4bc917b04789caaf17c77
    type: set_value
	value: "{{ states('sensor.victronzon') | float }}"
mode: single

If you can, use the entity ID for your number rather than the device ID.

action:
  - service: number.set_value
    data:
      value: "{{ states('sensor.victronzon') | float(0) }}"
    target:
      entity_id: number.ENTITY_ID

That rarely ends in success.

alias: Handelen met energie - Handmatig ontladen snel + zon
description: ""
trigger:
  - platform: state
    entity_id:
      - input_button.handmatig_ontladen_snel_zon
condition: []
action:
  - service: number.set_value
    data:
      value: "{{ states('sensor.victronzon') | float(0) }}"
    target:
      entity_id: number.victron_settings_ess_acpowersetpoint_100
mode: single

This indeed works!

1 Like