@wighdeas (Wighdeas) posted a new topic, subject "How to create statistic values for "Energy" consumption page?". It read:

   Hi all,
    
    i recently added the Kostal Solar integration and now receive a lot of data, which are quite useful, eg, Energy consumption of current month, current power consumption,…
    
    Now i thought i could use one of them for my energy calculation but i keep receiving the notification that there are no statistic values available:
    
    image1744×1320 140 KB
    
    I already created a code into my configuration.yaml:
    [code] 
        #Power
        customize: !include customize.yaml
        
    [/code]
    
    and my customize.yaml
    [code] 
        #Power
        customize_glob:
        sensor.scb_energy_yield_month:
            unit_of_measurement: kWh
            device_class: energy
            friendly_name: Hausverbrauch aktueller Monat
            state_class: measurement
            last_reset: '1970-01-01T00:00:00+00:00'
        
    [/code]
    
    as i ready some of it in the forum but i still get the notification of non-existent statitics.
    
    Can somebody please give me quick guideline on how i get my power consumption/costs ect. work via the Energy-Page?
    
    Would be very happy.

@tom_l replied

    `customize:` must be under homeassistant.
    [code] 
        homeassistant:
          customize: !include customize.yaml
        
    [/code]
    
    For an entity to be added to the energy dashboard it must have the state class:
    [code] 
        state_class: total_increasing 
        
    [/code]
    
    Not `measurement`.
    
    Also you dont need the `last_reset` attribute and that should be removed.
    
    You can read more here: https://developers.home-assistant.io/docs/core/entity/sensor/#how-to-choose-state_class-and-last_reset

So @wighdeas (Wighdeas) replied

    Hi @tom_l , many thanks for the fast reply.
    
    So i changed the code accordingly, but still no appearance. Also a already checked the page you recommended. Ist the path `/config/customize.yaml` correct for the customize-file?
    
    Ist there any way i can check why it's not working/showing up?

After which, @tom_l added

    This is what you should have, take note of the indentation:
    [code] 
        homeassistant:
          customize_glob: # you don't have any of these so you can remove this line if you like
          customize: !include customize.yaml
        
    [/code]
    
    Then put this in that new file /config/customize.yaml
    [code] 
        # Energy
        sensor.scb_energy_yield_month:
          unit_of_measurement: kWh
          device_class: energy
          friendly_name: Hausverbrauch aktueller Monat
          state_class: total_increasing
        
    [/code]

So @wighdeas (Wighdeas) replied

    So after i added some sensors from my Kostal-Integration, two of them actually showed up in the dropdown, which made me quite happy. Even though knowing that “total consumption from grid” is not the correct parameter, i picked it for testing. Now it seems to work. HA then appearantly created an own sensor (the last one on the very bottom):
    
    image2184×816 104 KB
    
    So progress yes, perfect no. How can i alter the sources for “Energy” once i set them up initially?! (see next post as i can only add one embedde picture)
    
    there seems to be no “Edit”-button or else. As “Energy” is also not an integration or add-on (correct me if I'm wrong), i don't know how to change the parameters.

Then @wighdeas (Wighdeas) said

    here the picture:  
    
    
    image2226×1522 130 KB

To which @tom_l replied

    wighdeas:
    
    > there seems to be no “Edit”-button or else. As “Energy” is also not an integration or add-on (correct me if I'm wrong), i don't know how to change the parameters.
    
    Go back to the Configuration / Dashboards / Energy settings page and you will see a pencil icon and a garbage bin next to each sensor you have added. Pencil = edit, garbage = delete.

@wighdeas (Wighdeas) replied

    Found it! in my GUI it's three little dots which are barely clickable but seems to be a resolution issue, shame on me. Thanks for that. What i discovered is that if a activate sensors from my Kostal-Integration get available in the dropdown:  
    
    
    image1202×1341 140 KB
    
    but the “custom made” ones are not availble. So i assume i configured the file not correct or sth. I tried it by costumzie a sensor so it will be the same setup as one of the generic ones which are available:
    
    generic one (available in dropdown):
    [code] 
        state_class: total_increasing
        unit_of_measurement: kWh
        device_class: energy
        friendly_name: scb Home Consumption from Grid Total
        
    [/code]
    
    customized one (not available in dropdown):
    [code] 
        sensor.scb_home_consumption_from_grid_month:
            unit_of_measurement: kWh
            device_class: energy
            friendly_name: scb Home Consumption from Grid Month
            state_class: total_increasing
        #    last_reset: '1970-01-01T00:00:00+00:00'
        
    [/code]
    
    So two possible issues to be assumed:
    
      1. The customized sensor cannot be accessed/detected
      2. The Energy-Dashboard accepts only “total-total” values as my customized is “per month”.
    
    
    
    Any ideas?

So @tom_l replied

    Did you restart after updating the customizations?
    
    Or reload “Location & Cutomizations”?

To which @wighdeas (Wighdeas) replied

    Yes, i reloaded the whole HA application and as the generic sensors keep appearing in the dropdown the issue only affects customized sensors. Nevertheless maybe it's even correct to have “total consumption” over “consumption of current month” and HA itself then limits the period of observation by day, month, etc., might that be right?
    
    Because i now chose the total amounts of each and it seems to work (correct me if I'm wrong):
    
    image2230×1350 140 KB
    
    But still bothers me that i cannot use customized sensors as they should be set up the very same and i could image that this problem will affect me someday again


{'source': 'discourse', 'url': 'https://community.home-assistant.io/t/how-to-create-statistic-values-for-energy-consumption-page/392779', 'title': 'How to create statistic values for "Energy" consumption page?', 'views': 785, 'has_accepted_answer': False, 'word_count': 818, 'like_count': 0, 'reply_count': 6, 'participant_count': 2, 'posts': 10, 'tags': '', 'author': '@wighdeas (Wighdeas)', 'participants': '@wighdeas (Wighdeas), @tom_l', 'image_url': ['https://community-assets.home-assistant.io/optimized/4X/6/3/3/633a7948ff658adc81902fec22a97b353a8cd0a2_2_1024x775.png'], 'created_at': '2022-02-14T19:17:16.076Z', 'last_posted_at': '2022-02-15T10:57:53.480Z'}