#how do I format the above so it can go
1 messages · Page 1 of 1 (latest)
You don't - that's a new style template sensor and doesn't go under sensor:
You could do
template: !include template.yaml
and then template.yaml would be:
- sensor:
- name: Grid Import Power
state_class: measurement
icon: mdi:transmission-tower
unit_of_measurement: W
device_class: power
state: >
{{ [0, states('sensor.envoy_SERIALNUMBER_current_power_consumption') | int - states('sensor.envoy_SERIALNUMBER_current_power_production') | int ] | max }}
- name: Grid Export Power
state_class: measurement
icon: mdi:transmission-tower
unit_of_measurement: W
device_class: power
state: >
{{ [0, states('sensor.envoy_SERIALNUMBER_current_power_production') | int - states('sensor.envoy_SERIALNUMBER_current_power_consumption') | int ] | max }}
thank you, I think I was getting closer.
I had
template:
- sensor: !include sensor.yaml
then
- name: Solar Power Corrected
state_class: measurement
icon: mdi:solar-panel
unit_of_measurement: W
device_class: power
state: >
{% set value = states('sensor.envoy_xx_current_power_production') | int(0) %}
{% if value <= 5 -%}
0
{% elif is_state('sun.sun','below_horizon') %}
0
{%- else -%}
{{ value }}
{%- endif %}
To format your text as code, enter three backticks on the first line, press Shift+Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.
which I think is fine until later in the sensor.yaml when I start trying to specify platform:
Yeah, you can't mix different formats
thank you for your help I'll implement how you suggested
Your approach will be fine, as long as you don't duplicate sensor: in sensor.yaml