Need help logic

Hello
i am new with Yaml… locking to transform a value to text
the value that is return 0 or 1
would like to see . On or Off

  - name: "MQTT Charger on/off"
    hub: victron
    data_type: uint
    slave: 239
    register: 774
    value_template: '{% if is_state("MQTT Charger on/off","1") %} On
                     {% elif is_state("MQTT Charger on/off","2") %} Off
                     {% endif %}'

Error Message:

Invalid config for [sensor.modbus]: [value_template] is an invalid option for [sensor.modbus]. Check: sensor.modbus->registers->11->value_template. (See ?, line ?).

Probably you want a binary sensor instead then. However, if you look at the documentation you’ll see neither supports value_template, hence the error about it being invalid :wink:

hum… binary sensor does not work with those MQTT victron sensor

i try the binary Sensor but not working…

binary_sensor:

  • platform: modbus
    inputs:
    • name: test binary_sensor
      hub: victron
      slave: 238
      address: 259

Invalid config for [sensor.modbus]: expected a list for dictionary value @ data[‘registers’]. Got None. (See ?, line ?).
Invalid config for [binary_sensor.modbus]: [data_type] is an invalid option for [binary_sensor.modbus]. Check: binary_sensor.modbus->inputs->1->data_type. (See ?, line ?).

Unfortunately you forgot to mark your code as, well, code. Please edit your post and use code mark-up :wink:

Configure a default setup of Home Assistant (frontend, api, etc)

default_config:

Text to speech

tts:

  • platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
modbus: !include modbus.yaml
lovelace: !include lovelace.yaml

#sensors: !include_dir_merge_list /config/sensors/
homeassistant:
customize: !include customize.yaml

sensor:

  • platform: sensorpush

– HOME SYSTEM

Modbus device (slave) IDs: /!\ Only for my system

BMV 238

MPPT 239

Main System 100

  • platform: modbus
    scan_interval: 00:00:15
    registers:

BMV 238

 - name: "BMV Battery voltage"
   hub: victron
   data_type: uint
   unit_of_measurement: "V"
   slave: 238
   register: 259
   scale: 0.01
   precision: 2
   value_template: >-
    {{ is_state('sensor.mptt_charger_on_off', 1 ),
         on
     {{ elif is_state('sensor.mptt_charger_on_off',
         off

That’s still not formatted correctly. To properly format:

  1. Copy the information from your configuration (NOT THE OTHER POST YOU MADE)
  2. Paste it into a new post.
  3. Put 3 backticks ``` before the code chunk.
  4. Put 3 backticks ``` after the code chunk.
  5. Done.
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
modbus: !include modbus.yaml
#sensors: !include_dir_merge_list /config/sensors/
homeassistant:
  customize: !include customize.yaml

sensor:
   - platform: sensorpush
   
# -- HOME SYSTEM
 # Modbus device (slave) IDs: /!\ Only for my system
 # BMV               238
 # MPPT              239
 # Main System       100
   - platform: modbus
     scan_interval: 00:00:15
     registers:
value_template: >-
    {{ is_state('sensor.mptt_charger_on_off', 1 ),
         on
     {{ elif is_state('sensor.mptt_charger_on_off',
         off