binsentsu / home-assistant-solaredge-modbus

Home assistant Component for reading data locally from Solaredge inverter through modbus TCP
281 stars 70 forks source link

Wiki: typo in config for TeslaStylePowerCard #61

Closed ChristophCaina closed 1 month ago

ChristophCaina commented 2 years ago

There's a small issue with the configuration.yaml for the Power Flow...

power_self_consumption:                                            
        friendly_name: "Power - Self Consumption"                               
        unit_of_measurement: "W"           
        # Self consumption of solar generation is inverter output, minus what is being exported to grid                                 
        value_template: "{{ (states('sensor.solaredge_modbus_i1_ac_power') | float)) - states('sensor.power_grid_export') | float}}" 

should be:

power_self_consumption:                                            
        friendly_name: "Power - Self Consumption"                               
        unit_of_measurement: "W"           
        # Self consumption of solar generation is inverter output, minus what is being exported to grid                                 
        value_template: "{{ (states('sensor.solaredge_modbus_i1_ac_power') | float) - (states('sensor.power_grid_export') | float) }}" 

Additionally, the flow is going from "Home" to "Solar" instead of "Solar" to "Home" grafik

mpredfearn commented 2 years ago

@ChristophCaina sorry I don't have this configuration in order to test it for the docs, I based it on the discussion here https://github.com/binsentsu/home-assistant-solaredge-modbus/issues/55#issuecomment-938508104 where @lukeprior gave his configuration. It would be most helpful if you could work out what the correct maths is in order to fix the documentation. Are the other flows, specifically power_grid_export and power_grid_import correct in direction and magnitude?

ChristophCaina commented 2 years ago

Hi @mpredfearn : I think, the issue was related to the naming of the sensor.

(states('sensor.solaredge_modbus_i1_ac_power') should be (states('sensor.solaredge_modbus_m1_ac_power')

ChristophCaina commented 2 years ago

ok, had a look into the pull requests. It seems that the i1_ac_power came from pullrequest #12 where a change for multiple inverters has been made. In this case, I expect the i1 as a counter for the inverter...

WillCodeForCats commented 2 years ago

In a multi-inverter setup you can have all of:

sensor.solaredge_i1_ac_power sensor.solaredge_i2_ac_power ... sensor.solaredge_m1_ac_power

If you have multiple inverters, you will want sensor.solaredge_i1_ac_power + sensor.solaredge_i2_ac_power (etc. for however many inverters you have).

ChristophCaina commented 2 years ago

ok, that should be highlighted in the Wiki page then. I think, the wiki should include examples with the most likely setup - which I think is a one-inverter setup... or?

mpredfearn commented 2 years ago

@ChristophCaina yes, most likely - but I don't have such a system to verify the sensors with. If you could post your (working) template sensors then the wiki can be updated. Note that I don't think (states('sensor.solaredge_modbus_i1_ac_power') should be (states('sensor.solaredge_modbus_m1_ac_power') As @WillCodeForCats says, the "i1" is there because I am running a branch with multiple inverter support and forgot to remove it from there.

ChristophCaina commented 2 years ago

yes, the i1 comes from the inverter. Since I only have one inverter, I've replaced this with the modbus_ac_power (without inverter-Number) ... and then it worked.

here's my working code... But note, since my solar-installation does prevent me from importing much energy from the grid during the day, I can only veryfy the flow from production to grid at the moment.

# Power Flow for Tesla Style Power Card
    power_grid_import:                                                    
      friendly_name: "Power - Grid Import"                                    
      unit_of_measurement: "W"    
      # Grid import to loads is negative values of import / export meter
      value_template: "{{ (states('sensor.solaredge_modbus_m1_ac_power') | float | min(0) | abs()) }}"
    power_grid_export:                                                     
      friendly_name: "Power - Grid Export"                                    
      unit_of_measurement: "W"   
      # Grid export is positive values of import / export meter
      value_template: "{{ states('sensor.solaredge_modbus_m1_ac_power') | float | max(0) }}"                                                                                                                                                   
    power_consumption:                                                  
      friendly_name: "Power - Consumption"                                    
      unit_of_measurement: "W"       
      # House consumption is inverter output minus import / export meter flow
      value_template: "{{ (states('sensor.solaredge_modbus_ac_power') | float) - (states('sensor.solaredge_modbus_m1_ac_power') | float) }}"
    power_self_consumption:                                            
      friendly_name: "Power - Self Consumption"                               
      unit_of_measurement: "W"           
      # Self consumption of solar generation is inverter output, minus what is being exported to grid                                 
      value_template: "{{ (states('sensor.solaredge_modbus_ac_power') | float) - (states('sensor.power_grid_export') | float) }}" 

grafik

ChristophCaina commented 2 years ago

BUT: the other question is... do we really need the tesla style power card? With the energy dashboard, HomeAssistant does come with its own card in a very similar style grafik

this can be used with type: energy-distribution and you don't need to care about any math etc... it's just providing the information from the sensors added to the energy dashboard and you can use the card wherever you want.

mpredfearn commented 2 years ago

OK cool thanks @ChristophCaina - wiki page updated with those sensors.

It depends what you want to see. The Tesla style card gives you the instantaneous power - i.e. power flows right now. The energy dashboard gives you the overall energy distribution for the day - both are useful, but they are very different things.

ChristophCaina commented 2 years ago

hi @mpredfearn, I don't know if it is correct to 'copy & paste' my code... I have renamed the integration to solaredge_modbus since I'm also using the cloud integration as well as some custom sensors. Therefore, I have added the type of the integration (solaredge_api, solaredge_modbus, etc.)

I think, the default is just solaredge - and should probably reflected in the wiki, too...

mpredfearn commented 2 years ago

Yeah I renamed it as well in exactly the same way - all of the other templated sensors are the same style - so it is consistent at least. I'll add a note on the page to reflect that. Possibly "solaredge" is the wong default domain for this integration.