In addition to the indentation issues described above:
You need to put your template sensor under sensor:, not sonoff:.
I don’t see a reason for using the legacy format of template sensor, but it should work. (Edit: but it won’t let you set the state_class that you’ll need for your energy sensor.)
I also don’t think http should be indented in your config. As it is right now, it is under sonoff instead of being a top-level key.
Because you haven’t posted your config in plain text (see point 11), I will only write the parts that need to change.
duplicated mapping key at line 35, column -168:
sensors:
^
and after testing config
Invalid config for [sensor.template]: expected dictionary for dictionary value @ data[‘sensors’][‘friendly_name’]. Got ‘voltage pump’ expected dictionary for dictionary value @ data[‘sensors’][‘unit_of_measurement’]. Got ’ V ’ expected dictionary for dictionary value @ data[‘sensors’][‘value_template’]. Got " {{ state_attr(‘switch.sonoff_1001489baa’ , ‘voltage’) }} ". (See ?, line ?).
PS: LINE 35 is the line that starts with the second command ‘sensor’ as per bellow
so I retype manually everything to understand the changes.
no error in the file editor, yes !!!
ut stil have error if I test the config before I want to start:
Integration error: platform - Integration ‘platform’ not found. Integration error: sensors - Integration ‘sensors’ not found.
ok i change:
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Text to speech
tts:
- platform: google_translate
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sonoff:
username: xxxxx
password: xxxxx
sensors: power, current, voltage, temperature, humidity, current
mode: local
reload: always
http:
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem
sensor:
- platform: template
sensors:
sonoff_1001489baa_current:
friendly_name: "courant pump"
value_template: "{{ state_attr('switch.sonoff_1001489baa', 'current'}}"
unit_of_measurement: "A"
sonoff_1001489baa_power:
friendly_name: "power pump"
value_template: "{{ state_attr('switch.sonoff_1001489baa', 'power'}}"
unit_of_measurement: "W"
sonoff_1001489baa_voltage:
friendly_name: "voltage pump"
value_template: "{{ state_attr('switch.sonoff_1001489baa', 'voltage'}}"
unit_of_measurement: "V"
But now error at line 20 :invalid config for [http]: [sensor] is an invalid option for [http]. Check: http->http->sensor. (See /config/configuration.yaml, line 20).
i retype manually everything, I’m really lost here, because it is exactly the same…then I tried also just to copy / paste your last script, but still get same message…
Ondras, you are right, these were not in the script…thank you so much it works now!!! thank you all for your help!
i understand now, same as mathematic formula if you start with ( you need a ) at the end …
no problem Tamsy you helped me a lot and you probably get confused with all my stupid questions again it works now… now I need to find a way to refresh these datas because it is static since 30 minutes…and get it integrated in energy board