MJPVDH
(Martin)
July 7, 2021, 7:56pm
143
I don’t understand it any more, I have the following in my system:
sensor.yaml
################################################################
# Solar Stuff #
################################################################
- platform: enphase_envoy
ip_address: 192.168.178.41
monitored_conditions:
- production
- daily_production
- seven_days_production
- lifetime_production
- consumption
- daily_consumption
- seven_days_consumption
- lifetime_consumption
- inverters
################################################################
# Solar Stuff (tesla-style-solar-power-card) #
################################################################
- platform: template
sensors:
envoy_house_consumption:
friendly_name: "Current House Consumption"
value_template: "{{ [0, (states('sensor.envoy_current_energy_production') | int - states('sensor.envoy_current_exporting') | int)] | max }}"
unit_of_measurement: 'W'
icon_template: 'mdi:flash'
envoy_current_exporting:
friendly_name: "Current Energy Exporting"
value_template: "{{ [0, (states('sensor.envoy_current_energy_production') | int - states('sensor.envoy_current_energy_consumption') | int)] | max }}"
unit_of_measurement: 'W'
icon_template: 'mdi:flash'
envoy_current_importing:
friendly_name: "Current Energy Importing"
value_template: "{{ [0, (states('sensor.envoy_current_energy_consumption') | int - states('sensor.envoy_current_energy_production') | int)] | max }}"
unit_of_measurement: 'W'
icon_template: 'mdi:flash'
envoy_today_s_energy_exporting:
friendly_name: "Today Energy Exporting"
value_template: "{{ [0, (states('sensor.envoy_today_s_energy_production') | int - states('sensor.envoy_today_s_energy_consumption') | int)] | max }}"
unit_of_measurement: 'Wh'
icon_template: 'mdi:flash'
envoy_today_s_energy_importing:
friendly_name: "Today Energy Importing"
value_template: "{{ [0, (states('sensor.envoy_today_s_energy_consumption') | int - states('sensor.envoy_today_s_energy_production') | int)] | max }}"
unit_of_measurement: 'Wh'
icon_template: 'mdi:flash'
envoy_today_s_consumption_negative:
value_template: '{{ ((states.sensor.envoy_today_s_energy_consumption.state | float * -1)) | round(1) }}'
friendly_name: 'Today Energy Consumption'
unit_of_measurement: 'Wh'
power_kw:
friendly_name: "Power Available"
unit_of_measurement: 'kW'
value_template: >
{% if states('sensor.envoy_current_exporting')|float > states('sensor.envoy_current_importing')|float %}
{{ (states('sensor.envoy_current_exporting') | int / 1000) | round(2)}}
{% else %}
{{ (states('sensor.envoy_current_importing') | int / -1000) | round(2)}}
{% endif %}
grid_consumption:
friendly_name: "Grid Consumption"
unit_of_measurement: 'W'
value_template: >
{% if states('ensor.envoy_current_energy_consumption') | int > 0 %}
0
{% else -%}
{{ (states('ensor.envoy_current_energy_consumption') | int) | abs }}
{% endif %}
grid_feed_in:
friendly_name: "Grid Feed In"
unit_of_measurement: 'W'
value_template: >
{% if states('ensor.envoy_current_energy_consumption') | int > 0 %}
{{ states('ensor.envoy_current_energy_consumption') }}
{% else -%}
0
{% endif %}
current_generation_to_house:
friendly_name: "Current Generation to House"
value_template: "{{ [0, (states('sensor.envoy_current_energy_production') | int - states('sensor.envoy_current_exporting') | int)] | max }}"
unit_of_measurement: 'W'
icon_template: 'mdi:flash'
In lovelace
type: custom:tesla-style-solar-power-card
generation_entity: sensor.envoy_current_energy_production
grid_to_house_entity: sensor.envoy_current_importing
generation_to_grid_entity: sensor.envoy_current_exporting
generation_to_house_entity: sensor.current_generation_to_house
I just compared my entity definitions with yours, and other than then names their definitions are exactly the same.
The other differences are that I have my Envoy integration defined via the UI, but that shouldn’t have any impact. I am on Home Assistant version 2021.6.6 at the moment. And, the last difference is that I currently do not have property generation_entity
defined in my card.
MJPVDH
(Martin)
July 8, 2021, 6:29pm
145
I have been watching it today. The weather was nice, so it was easy to watch!
At full power of the solar panels the orange balls go to the house consumption and to the export grid. So that goes well.
As soon as the solar panels start delivering less and they have to be imported from the grid, things go wrong and the value of the solar panels drops.
the picture below is when there is export to grid and home from the solar panels. Then it does go well.
One thing I found very helpful in setting up the cards was to use the Template tab in Developer Tools to see what the various template values were doing during the day, to assist with debugging.
The frontend has a template editor tool to help develop and debug templates. Navigate to Developer Tools > Template , create your template in the Template editor and check the results on the right.
1 Like
fhopley
(Fhopley)
July 11, 2021, 12:09am
147
Hi @reptilex … thank you so much for creating this card, it is extremely useful. I’ve managed to implement the card … see picture below, and added a few extra_entity fields which I’d like to improve. Specifically, the total generation & consumption entities I’d like to convert to kWh (from Wh). Here is the sensor specification that I guessed at, but which doesn’t work.
tesla_card_generation_kWh:
friendly_name: "Total Generation Today"
value_template: "{{ (sensor.envoy_122108000251_today_s_energy_production / 1000 ) | round(1) }}"
unit_of_measurement: "kWh"
Here is the error I receive when checking my configuration.yaml
“Invalid config for [sensor.template]: invalid slug tesla_card_generation_kWh”
That string must be all lower-case.
fhopley
(Fhopley)
July 11, 2021, 4:22am
149
Thanks @exxamalte that helps, and likely shows my ignorance. I’ve edited the code, and configuration accepts it, and included the sensor in the card. After a restart the value of the sensor is ‘unavailable’ - see pics below. Note that the envoy sensor definitely is available and giving values if put into the card (or via developer tools : states). The new sensor likewise shows as unavailable in developer tools.
tesla_card_generation_kwh:
friendly_name: "Total Generation Today"
value_template: "{{ (sensor.envoy_122108000251_today_s_energy_production / 1000 ) | round(1) }}"
unit_of_measurement: "kWh"
fhopley
(Fhopley)
July 11, 2021, 6:21am
150
I solved my problem, for the newbies that might benefit I’ve attached the working sensor code below. It includes using the states function and converting the sensor output to a float.
tesla_card_generation_kwh:
friendly_name: "Total Generation Today"
value_template: "{{ (states('sensor.envoy_122108000251_today_s_energy_production') | float / 1000 ) | round(0) }}"
unit_of_measurement: "kWh"
2 Likes
nuki47
(Nuki47)
July 24, 2021, 6:35am
151
Where is my bug, because I have only a very small flow picture?
olaldiko
(Gorka Olalde Mendia)
July 28, 2021, 6:57am
152
For someone with a Fronius inverter and the custom integration by Safepay, here are the template sensors and the config for the card that I’m using!
solar_to_grid:
unit_of_measurement: "W"
value_template: >
{% if float(states('sensor.fronius_grid_usage')) < 0 %}
{{ float(states('sensor.fronius_grid_usage')) | abs }}
{% else %}
0
{% endif %}
solar_to_house:
unit_of_measurement: "W"
value_template: >
{% if float(states('sensor.fronius_ac_power')) > (float(states('sensor.fronius_house_load')) * -1) %}
{{ float(states('sensor.fronius_house_load')) | abs }}
{% else %}
{{ float(states('sensor.fronius_ac_power')) }}
{% endif %}
grid_to_house:
unit_of_measurement: "W"
value_template: >
{% if states('sensor.fronius_grid_usage') | int > 0 %}
{{ states('sensor.fronius_grid_usage') }}
{% else %}
0
{% endif %}
house_load_positive:
unit_of_measurement: "W"
value_template: >
{{float(states('sensor.fronius_house_load')) | abs }}
And card configuration:
- type: "custom:tesla-style-solar-power-card"
name: Produccion
grid_consumption_entity: sensor.grid_to_house
house_consumption_entity: sensor.house_load_positive
grid_to_house_entity: sensor.grid_to_house
generation_to_grid_entity: sensor.solar_to_grid
generation_to_house_entity: sensor.solar_to_house
grid_entity: sensor.fronius_grid_usage
house_entity: sensor.fronius_house_load
generation_entity: sensor.fronius_ac_power
Hope it helps!
3 Likes
Legend! Exactly what I need. I use a different device to monitor grid power but I should be able to tweak this to suit. Thank you so much.
EDIT: not sure why, but I’m getting the red card error. I tried re-installing the card, refreshed browser.
mang0
July 29, 2021, 10:07pm
154
Looks like an indentation issue (or hyphen issue?) according to some of the other posts with that error. Do you have more code before your card code you can post?
There shouldn’t be any indentation issues, it’s copied directly from your example with only a few entities modified.
It’s a card by itself so nothing before or after.
- type: custom:tesla-style-solar-power-card
name: Power Distribution
grid_consumption_entity: sensor.grid_to_house
house_consumption_entity: sensor.house_load_positive
grid_to_house_entity: sensor.grid_to_house
generation_to_grid_entity: sensor.solar_to_grid
generation_to_house_entity: sensor.solar_to_house
grid_entity: sensor.iotawatt_grid_total
house_entity: sensor.iotawatt_total_house_consumption
generation_entity: sensor.fronius_ac_power
mang0
July 30, 2021, 3:56am
156
(I assume you added the lovelace resources.)
Is it just a dashboard view with:
views:
- title:
cards:
- type:
Well installing the card through HACS should do that for me…
… and I can confirm that the resource is there:
I’m not running Lovelace in YAML mode so the above code is literally all I need to add any card to an existing Lovelace view.
I did have another look and realised my stupid mistake however. Since I’m not using YAML mode I needed to remove the preceding dash at the start.
In this case you don’t need any indentation nor hyphen at the start.
Fermax
August 1, 2021, 12:14am
159
As per Yassith and nuki47’s posts above, my card is appearing scaled-down to dots:
The full-size card appears very briefly, then shrinks to the above.
It seems to work after a reboot of the Core, but later goes to a small diagram again.
Any ideas on what might be causing this?
Really love this card both functional and design, qq - is there a way of increasing the font size of the values presented?
Yes I would like this also
JustDFB
(DFB)
October 12, 2021, 11:55pm
162
Hi fhopley,
Thanks for posting your solution on the sensor.
Stupid question - how do you get the totals showing above the icon?
cheers
JDFB