Home Assistant : Q&A, Tips & Tricks, Your Configs

Speedster

Honorary Master
Joined
May 2, 2006
Messages
21,685
No pool or gate but geysers, small solar setup (mecer axpert), garage doors, 3d printers, fish tank comes to mind.
All of those can be hooked up with the appropriate smart switches. Not quite sure if Mecer integrates though
 

B-1

Executive Member
Joined
Apr 17, 2020
Messages
5,546
All of those can be hooked up with the appropriate smart switches. Not quite sure if Mecer integrates though

Thanks, yes will try and see what will be useful. The solar setup is probably the most likely candidate.
 

Priapus

Honorary Master
Joined
Jun 8, 2008
Messages
11,422
Yeah that screenshot is from my own home assistant.

View attachment 1120238

Interesting...its suppose to render client side? Works fine for me.

This is my code (mostly copied from another user):
Code:
type: custom:apexcharts-card
graph_span: 36h
span:
  start: day
  offset: '-6h'
header:
  show: true
  title: Solar Production vs. forecast
  show_states: true
now:
  show: true
  label: now
apex_config:
  legend:
    show: false
series:
  - entity: sensor.goodwe_ppv
    name: Actual
    unit: W
    fill_raw: last
    extend_to_end: false
    group_by:
      func: avg
      duration: 30min
  - entity: sensor.solcast_forecast_average_30min
    transform: return x * 1000;
    name: Forecast
    unit: W
    fill_raw: last
    extend_to_end: false
  - entity: sensor.solcast_forecast_data
    type: line
    extend_to_end: false
    unit: W
    show:
      in_header: false
    data_generator: |
      return entity.attributes.forecasts.map((entry) => {
         return [new Date(entry.period_end), entry.pv_estimate*1000];
       });

Source: https://community.home-assistant.io...ls-on-post-to-external-url-solcast/143238/116

Are you using th Forecast integration? I've installed that integration and trying to get this card to work; but the forecast line doesn't show. My sensor names are different thank yours for forecasting, hence the question.
 
Last edited:

Priapus

Honorary Master
Joined
Jun 8, 2008
Messages
11,422
I’m really like those horizontal bar graphs. Looks a lot nicer than the gauges I’m running now.

Also, you using the new Solar Forecast from HA or you still using Solcast? That production vs Forecast graph is awesome

I'm with you there. I use gauges at the moment; but those bar graphs look much better. I see a rework in my very near future of my energy panel.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
12,478
I’m really like those horizontal bar graphs. Looks a lot nicer than the gauges I’m running now.

Also, you using the new Solar Forecast from HA or you still using Solcast? That production vs Forecast graph is awesome
Well I will be honest. I have 3 things.

1. solcast custom integration https://github.com/dannerph/homeassistant-solcast
Most of my automations for turning on geysers, pool, setting DoD on inverter is using sensors from this.

2. New solar forecast from HA
I installed this to test and play with. I find its less accurate than solcast but biggest problem is, it doesn't reduce the kWh left for the day which the above integration does and I use that to trigger DoD automations to allow me to preserve battery towards the end of the day.

This is the only one that works with the new energy dashboard released in 2021.08.01 yesterday.

3. solcast using rest directly and then set up template sensors.
I literally added to to get the apexcharts working, because the example and that chart I directly copied from someone using the rest directly.
See: https://community.home-assistant.io...ls-on-post-to-external-url-solcast/143238/116

Code:
sensor:
  - platform: rest
    name: solcast_forecast_data
    json_attributes:
      - forecasts
    resource: https://api.solcast.com.au/rooftop_sites/SOLCAST_RESOURCE_ID/forecasts?format=json&api_key=SOLCAST_API_KEY
    method: GET
    value_template: "OK"
    scan_interval: 01:00
    force_update: true
  - platform: template
    sensors:
        solcast_forecast_average_30min:
            value_template: "{{ state_attr('sensor.solcast_forecast_data', 'forecasts')[0].pv_estimate|default('variable is not defined')|round(2) }}"
            unit_of_measurement: 'kW'
        solcast_forecast_average_60min:
            value_template: >-
              {{ ((state_attr('sensor.solcast_forecast_data', 'forecasts')[0].pv_estimate|default('variable is not defined') + state_attr('sensor.solcast_forecast_data', 'forecasts')[1].pv_estimate|default('variable is not defined'))/2)|round(2) }}
            unit_of_measurement: 'kW'
        solcast_forecast_today:
            value_template: >-
              {% set ns = namespace (fc_today = 0) %}
              {% for forecast in state_attr('sensor.solcast_forecast_data', 'forecasts')|default('variable is not defined') %}
                {% set daydiff = as_local(strptime(forecast.period_end, '%Y-%m-%dT%H:%M:%S.%f0Z').replace(tzinfo=utcnow().tzinfo)).date() - as_local(utcnow()).date() %}
                {% if daydiff.days == 0 %}
                  {% set ns.fc_today = ns.fc_today + (forecast.pv_estimate/2)|float %}
                {%- endif %}
              {%- endfor %}
              {{ ns.fc_today|round(2) }}
            unit_of_measurement: 'kWh'
        solcast_forecast_today_max:
            value_template: >-
              {% set ns = namespace (fc_today_max = 0) %}
              {% for forecast in state_attr('sensor.solcast_forecast_data', 'forecasts')|default('variable is not defined') %}
                {% set daydiff = as_local(strptime(forecast.period_end, '%Y-%m-%dT%H:%M:%S.%f0Z').replace(tzinfo=utcnow().tzinfo)).date() - as_local(utcnow()).date() %}
                {% if daydiff.days == 0 %}
                  {% if ns.fc_today_max < forecast.pv_estimate|float %}
                    {% set ns.fc_today_max = forecast.pv_estimate|float %}
                  {%- endif %}
                {%- endif %}

Then you can do:
Code:
type: custom:apexcharts-card
graph_span: 36h
span:
  start: day
  offset: '-6h'
header:
  show: true
  title: Solar Production vs. forecast
  show_states: true
now:
  show: true
  label: now
apex_config:
  legend:
    show: false
series:
  - entity: sensor.goodwe_ppv
    name: Actual
    unit: W
    fill_raw: last
    extend_to_end: false
    group_by:
      func: avg
      duration: 30min
  - entity: sensor.solcast_forecast_average_30min
    transform: return x * 1000;
    name: Forecast
    unit: W
    fill_raw: last
    extend_to_end: false
  - entity: sensor.solcast_forecast_data
    type: line
    extend_to_end: false
    unit: W
    show:
      in_header: false
    data_generator: |
      return entity.attributes.forecasts.map((entry) => {
         return [new Date(entry.period_end), entry.pv_estimate*1000];
       });
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
12,478
Are you using th Forecast integration? I've installed that integration and trying to get this card to work; but the forecast line doesn't show. My sensor names are different thank yours for forecasting, hence the question.
See my above reply to gbyleveldt

I needed to use rest api directly from solcast to get the complete forecast line.
 

Priapus

Honorary Master
Joined
Jun 8, 2008
Messages
11,422
See my above reply to gbyleveldt

I needed to use rest api directly from solcast to get the complete forecast line.
Thanks. I’ll look into that. I’m considering deleting HA and starting from scratch. With more thought into everything. It’s a little bit of a mess at the moment.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
12,478
Thanks. I’ll look into that. I’m considering deleting HA and starting from scratch. With more thought into everything. It’s a little bit of a mess at the moment.
Yeah a lot of it is trial and error too unfortunately. Over time you also learn how to do things better, but I think I was lucky that I early on split things into package yaml files so fairly easy to remove specific stuff.
 

xrapidx

Honorary Master
Joined
Feb 16, 2007
Messages
40,312
Is there a trick to getting the energy dashboard up?

Can't seem to find it - or how.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
12,478
Add

energy:

To your config.
Interesting... I didn't have to do that? The pane auto appeared for me after the update.

What else could I have had beforehand that activates it? Maybe because I had the solar forecast integration enabled?
 

Priapus

Honorary Master
Joined
Jun 8, 2008
Messages
11,422
Yeah a lot of it is trial and error too unfortunately. Over time you also learn how to do things better, but I think I was lucky that I early on split things into package yaml files so fairly easy to remove specific stuff.

My issue is I have a lot of now unused or redundant sensors that I am trying to get rid of. Also HA has gotten buggy for me when editing as well. I don't know. Maybe a full clean up somehow will be better.
 

xrapidx

Honorary Master
Joined
Feb 16, 2007
Messages
40,312
Waiting patiently, as my lists are empty too.
Its all around configuration, just finished updating all mine...

Mine is off MQTT, so I needed to manually add the last_reset to all the sensors.
Code:
sensor.kitchen_fridge_power_today:
  last_reset: '1970-01-01T00:00:00+00:00'

and then add the correct properties:
Code:
- platform: mqtt
  name: "Kitchen Fridge Power (Today)"
  state_topic: "tele/KitchenFridge/SENSOR"
  qos: 0
  unit_of_measurement: "kWh"
  value_template: "{{ value_json['ENERGY'].Today }}"
  device_class: energy
  state_class: measurement
 

calypso

Expert Member
Joined
Feb 10, 2009
Messages
1,857
My stats show perfectly on the states page, but the energy dashboard cant pick up anything.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
12,478
I just created utility meter for each device I want to add to the energy dashboard
 
Top