Open spitfire opened 1 year ago
You were missing a few brackets in your multi sensor. Try below replacing your sensors.
{{ ((states('sensor.kitchen_socket_local_power') | float ) + (states('sensor.kitchen_fridge_socket_local_power') | float ) + (states('sensor.living_room_socket_local_power') | float )) | round(0) }}
You were missing a few brackets in your multi sensor. Try below replacing your sensors.
{{ ((states('sensor.kitchen_socket_local_power') | float ) + (states('sensor.kitchen_fridge_socket_local_power') | float ) + (states('sensor.living_room_socket_local_power') | float )) | round(0) }}
Are you sure this is relevant to my issues? I'm trying to get 3 parameters out of the Tuya device, the first template is working just fine. When I add the entries for Tuya, not so much anymore.
Nope not at all, I just noticed the yaml wasn't the way I do it, and when I copied yours into the template tool I got errors. Ignore that one if it is fine for you
I have to seperate my templates and repeat the - platform line each time, maybe try that?
- platform: template
sensors:
energia_czynna_aktualnie_pobierana:
friendly_name: "Energia czynna aktualnie pobierana"
device_class: energy
value_template: >-
{{ (states('sensor.electricity_meter_power_active_phase_1')|float + states('sensor.electricity_meter_power_active_phase_2')|float + states('sensor.electricity_meter_power_active_phase_3')|float) | round(0) }}
unit_of_measurement: "W"
- platform: template
sensors:
tuya-sw01_voltage:
value_template: >-
{{ states.switch.aubess_smart_socket_20a_em_serwerownia.attributes.voltage }}
unit_of_measurement: 'V'
- platform: template
sensors:
tuya-sw01_current:
value_template: >-
{{ states.switch.aubess_smart_socket_20a_em_serwerownia.attributes.current }}
unit_of_measurement: 'mA'
- platform: template
sensors:
tuya-sw01_current_consumption:
value_template: >-
{{ states.switch.aubess_smart_socket_20a_em_serwerownia.attributes.current_consumption }}
unit_of_measurement: 'W'
To confirm, when you paste the following into the template tool it works?
- platform: template
sensors:
tuya-sw01_voltage:
value_template: >-
{{ states.switch.aubess_smart_socket_20a_em_serwerownia.attributes.voltage }}
unit_of_measurement: 'V'
Thanks a lot for your reply! Tried this, and it still fails the "Check configuration" in "Developer tools"
- platform: template
sensors:
energia_czynna_aktualnie_pobierana:
friendly_name: "Energia czynna aktualnie pobierana"
device_class: energy
value_template: >-
{{ (states('sensor.electricity_meter_power_active_phase_1')|float + states('sensor.electricity_meter_power_active_phase_2')|float + states('sensor.electricity_meter_power_active_phase_3')|float) | round(0) }}
unit_of_measurement: "W"
- platform: template
sensors:
tuya-sw01_voltage:
value_template: >-
{{ states.switch.aubess_smart_socket_20a_em_serwerownia.attributes.voltage }}
unit_of_measurement: "V"
Invalid config for [sensor.template]: invalid slug tuya-sw01_voltage (try tuya_sw01_voltage) for dictionary value @ data['sensors']. Got OrderedDict([('tuya-sw01_voltage', OrderedDict([('value_template', '{{ states.switch.aubess_smart_socket_20a_em_serwerownia.attributes.voltage }}'), ('unit_of_measurement', 'V')]))]). (See ?, line ?).
attaching visual representation of the config, so that you can see the whitespace:
Hi! Because you only use one value and not add several, I think you should replace "value_template:" with "state:" in the second part of the code:
Does not work when added as is (GitHub breaks formatting, so that's why I'm sending screenshots) . When I added line break this happens so it seems it needs to be value_template, not a state.
I'm trying to set up Aubess Smart Socket 20A/EM (entity name is
switch.aubess_smart_socket_20a_em_serwerownia
)
corrected entity name - it is "switch.aubess_smart_socket_20a_em_serwerownia", not "aubess_smart_socket_20a_em_serwerownia.attributes" if that matters.
I'm trying to set up Aubess Smart Socket 20A/EM (entity name is
switch.aubess_smart_socket_20a_em_serwerownia
)corrected entity name - it is "switch.aubess_smart_socket_20a_em_serwerownia", not "aubess_smart_socket_20a_em_serwerownia.attributes" if that matters.
So... Try this with both variants with "state:" and next time with "value_template:" with correct entity name, but with this formatting below - inside the curly braces; closed with braces; and closed between upper commas. That's what I can suggest... I'm sorry if it can't fix. I'm not so good in programming.
Create instead 3 additional sensors with config.
So... Try this with both variants with "state:" and next time with "value_template:" with correct entity name, but with this formatting below - inside the curly braces; closed with braces; and closed between upper commas. That's what I can suggest... I'm sorry if it can't fix. I'm not so good in programming.
Unfortunately that didn't work either. thanks for trying though
Create instead 3 additional sensors with config.
What do you mean? I think I understand the basics, but I'm pretty new to it.
These are absolutely correct. They work for me... Stop using the config and get it working under Developer Tools / Template first. Do one sensor at a time, and only add them to your config once you confirm they give you what you want.
- platform: template
sensors:
energia_czynna_aktualnie_pobierana:
friendly_name: "Energia czynna aktualnie pobierana"
device_class: energy
value_template: >-
{{ ((states('sensor.kitchen_socket_power') | float ) + (states('sensor.kitchen_fridge_socket_power') | float ) + (states('sensor.living_room_socket_power') | float )) | round(0) }}
unit_of_measurement: "W"
- platform: template
sensors:
tuya-sw01_voltage:
state: >-
{{ states.sensor.gym_desk_socket_power.attributes.raw_state }}
unit_of_measurement: "W"
Result type: string
- platform: template
sensors:
energia_czynna_aktualnie_pobierana:
friendly_name: "Energia czynna aktualnie pobierana"
device_class: energy
value_template: >-
167
unit_of_measurement: "W"
- platform: template
sensors:
tuya-sw01_voltage:
state: >-
81.1
unit_of_measurement: "W"
This template listens for the following state changed events:
Entity: sensor.gym_desk_socket_power
Entity: sensor.kitchen_fridge_socket_power
Entity: sensor.kitchen_socket_power
Entity: sensor.living_room_socket_power
We don't have your sensor names and IDs. You need to make sure the sensor id and the attribute id are correct for your sensors. If you don't know for certain look at the entity/device in the Developer Tools / States and confirm. I have just used some of mine that I know have W units or attributes to test the code. Once you get the code working all you need to change is the entity id, so just do it once and then replicate once working.
So... Try this with both variants with "state:" and next time with "value_template:" with correct entity name, but with this formatting below - inside the curly braces; closed with braces; and closed between upper commas. That's what I can suggest... I'm sorry if it can't fix. I'm not so good in programming.
Unfortunately that didn't work either. thanks for trying though
Create instead 3 additional sensors with config.
What do you mean? I think I understand the basics, but I'm pretty new to it.
When configuring through gui, first set switch entity, then uncheck do nod add more entities, and add 3 more sensor type entity with corresponding IDs and class {current, power, voltage). I can later post screenshots if you wouldn't success.
These are absolutely correct. They work for me... Stop using the config and get it working under Developer Tools / Template first. Do one sensor at a time, and only add them to your config once you confirm they give you what you want.
- platform: template sensors: energia_czynna_aktualnie_pobierana: friendly_name: "Energia czynna aktualnie pobierana" device_class: energy value_template: >- {{ ((states('sensor.kitchen_socket_power') | float ) + (states('sensor.kitchen_fridge_socket_power') | float ) + (states('sensor.living_room_socket_power') | float )) | round(0) }} unit_of_measurement: "W" - platform: template sensors: tuya-sw01_voltage: state: >- {{ states.sensor.gym_desk_socket_power.attributes.raw_state }} unit_of_measurement: "W"
Result type: string - platform: template sensors: energia_czynna_aktualnie_pobierana: friendly_name: "Energia czynna aktualnie pobierana" device_class: energy value_template: >- 167 unit_of_measurement: "W" - platform: template sensors: tuya-sw01_voltage: state: >- 81.1 unit_of_measurement: "W" This template listens for the following state changed events: Entity: sensor.gym_desk_socket_power Entity: sensor.kitchen_fridge_socket_power Entity: sensor.kitchen_socket_power Entity: sensor.living_room_socket_power
We don't have your sensor names and IDs. You need to make sure the sensor id and the attribute id are correct for your sensors. If you don't know for certain look at the entity/device in the Developer Tools / States and confirm. I have just used some of mine that I know have W units or attributes to test the code. Once you get the code working all you need to change is the entity id, so just do it once and then replicate once working.
Thanks for the info, didn't know about the template tool at all. The queries in the curly brackets do work (e.g. display right information):
But when I try to paste the same into configuration.yaml is when I get errors. I had the first template sensor in config for a long time and it worked, but when I try to add the tuya ones:
here's what happens in dev tools/yaml/check configuration:
It says it doesn't like the - in the entity name. Replace tuya-sw01 with tuya_sw01
Message ID: @.***>
It says it doesn't like the - in the entity name. Replace tuya-sw01 with tuya_sw01 …
ugh...thanks a lot! That was it. And that is exactly how it is written in Readme.md of this project - with a dash instead of underscore.
Sorry to bother you again, but based on the current consumption how can I get a meter that outputs the combined consumption in kWh from the current_consumption in Watts?
That's annoying isn't it!
You are looking to create a sum reimann integral sensor. Will look something like this
sensor:
- platform: integration
source: sensor.tuya_sw01_current_consumption
name: tuya_sw01_energy
unit_prefix: k
round: 2
method: left
Can also do this as a helper in GUI if you prefer. All the same settings are able to be selected.
Sorry for late respond. Here you go screenshots for configuring energy sensors. Then in helpers create sum for kWh and finally in helpers create monthly energy. Hope this helps...
@patrik-malina Thank you for the screenshots, they finally allowed me to get my Arlec Grid Connect smartplugs with energy monitoring working correctly after a dozen hours of messing around with no success. You're a lifesaver!
I'm trying to set up Aubess Smart Socket 20A/EM (entity name is
switch.aubess_smart_socket_20a_em_serwerownia
) for energy monitoring. I have the following config inconfiguration.yaml
for the- platform: template
section:and when I try to Check configuration in Developer tools I get the following error:
Configuration invalid!
Invalid config for [sensor.template]: invalid slug tuya-sw01_voltage (try tuya_sw01_voltage) for dictionary value @ data['sensors']. Got OrderedDict([('energia_czynna_aktualnie_pobierana', OrderedDict([('friendly_name', 'Energia czynna aktualnie pobierana'), ('device_class', 'energy'), ('value_template', "{{ (states('sensor.electricity_meter_power_active_phase_1')|float + states('sensor.electricity_meter_power_active_phase_2')|float + states('sensor.electricity_meter_power_active_phase_3')|float) | round(0) }}"), ('unit_of_measurement', 'W')])), ('tuya-sw01_voltage', OrderedDict([('value_template', '{{ states.switch.aubess_sm.... (See ?, line ?).