Comments (7)
Hi, you will need to fuze the two sensors on a single one using templates. Then feed that single sensor data passing the data as a list when calling the shell command, just as described in the documentation here: https://emhass.readthedocs.io/en/latest/forecasts.html#passing-your-own-forecast-data
from emhass.
Hi, did you find a solution for this?
from emhass.
Now I use for my rest sensors
- platform: rest
name: "Solcast Forecast huis"
json_attributes:
- forecasts
resource: https://api.solcast.com.au/rooftop_sites/xxxxxxxxxxc/forecasts?format=json&api_key=xxxxxxxxx&hours=24
method: GET
value_template: "{{ (value_json.forecasts[0].pv_estimate)|round(2) }}"
unit_of_measurement: "kW"
device_class: power
scan_interval: 86400
force_update: true
- platform: rest
name: "Solcast Forecast garage"
json_attributes:
- forecasts
resource: https://api.solcast.com.au/rooftop_sites/xxxxxxxxxxc/forecasts?format=json&api_key=xxxxxxxxx&hours=24
method: GET
value_template: "{{ (value_json.forecasts[0].pv_estimate)|round(2) }}"
unit_of_measurement: "kW"
device_class: power
scan_interval: 86400
force_update: true
Then i use 2 templates
solcast_24hrs_forecast_garage:
value_template: >-
{%- set awattar_all_list = state_attr('sensor.solcast_forecast_garage', 'forecasts') | map(attribute='pv_estimate') | list %}
{%- set values_all = namespace(all=[]) %}
{% for i in range(awattar_all_list | length) %}
{%- set v = (awattar_all_list[i] | float |multiply(1000) ) | int(0) %}
{%- set values_all.all = values_all.all + [ v ] %}
{%- endfor %} {{ (values_all.all)[:48] }}
solcast_24hrs_forecast_huis:
value_template: >-
{%- set awattar_all_list = state_attr('sensor.solcast_forecast_huis', 'forecasts') | map(attribute='pv_estimate') | list %}
{%- set values_all = namespace(all=[]) %}
{% for i in range(awattar_all_list | length) %}
{%- set v = (awattar_all_list[i] | float |multiply(1000) ) | int(0) %}
{%- set values_all.all = values_all.all + [ v ] %}
{%- endfor %} {{ (values_all.all)[:48] }}
And another to combine those 2
solcast_24hrs_forecast:
value_template: >-
{% set a = states("sensor.solcast_24hrs_forecast_garage")[1:-1].split(',') | map('int') | list %}
{% set b = states("sensor.solcast_24hrs_forecast_huis")[1:-1].split(',') | map('int') | list %}
{% set ns = namespace(items = []) %}
{% for i in range(a | length) %}
{% set ns.items = ns.items + [ a[i] + b[i] ] %}
{% endfor %}
{{ ns.items }}
I have 2 shell commands
publish_data: "curl -i -H 'Content-Type:application/json' -X POST -d '{}' http://localhost:5001/action/publish-data"
dayahead_optim: curl -i -H 'Content-Type:application/json' -X POST -d '{"pv_power_forecast":{{states('sensor.solcast_24hrs_forecast')}}}' http://localhost:5001/action/dayahead-optim
Then I use this automation
alias: EMHASS data
id: 684e7c96-7eb8-41fa-b81c-e3c97e234b56
trigger:
- platform: time
at: "05:30:00"
id: "dayahead"
- platform: time_pattern
minutes: /5
action:
- choose:
- conditions:
- condition: trigger
id: "dayahead"
sequence:
- service: homeassistant.update_entity
data: {}
target:
entity_id:
- sensor.solcast_forecast_garage
- sensor.solcast_forecast_huis
- delay:
minutes: 1
- service: shell_command.dayahead_optim
default:
- service: shell_command.publish_data
Do I have to leave method: solcast
in my configuration?
from emhass.
Great, thanks for sharing. Would you mind if I put some of this in the documentation? To help other people with the same use case?
No need to change the method, it will be automatically changed to list
when passing a list at runtime
from emhass.
I have two arrays east and west facing and provide this solution like this:
- platform: rest
name: "Solcast Forecast West"
json_attributes:
- forecasts
resource: https://api.solcast.com.au/rooftop_sites/4db1-7ec8-f883-c123/forecasts?format=json&api_key=XXXX&hours=48
method: GET
value_template: "{{ (value_json.forecasts[0].pv_estimate)|round(2) }}"
unit_of_measurement: "kW"
device_class: power
scan_interval: 06:00:00
force_update: true
- platform: rest
name: "Solcast Forecast East"
json_attributes:
- forecasts
resource: https://api.solcast.com.au/rooftop_sites/60b4-41b9-80ca-06b0/forecasts?format=json&api_key=XXXX&hours=48
method: GET
value_template: "{{ (value_json.forecasts[0].pv_estimate)|round(2) }}"
unit_of_measurement: "kW"
device_class: power
scan_interval: 06:00:00
force_update: true
- name: solcast 24hrs forecast
state: >-
{%- set solcast_west_list = state_attr('sensor.solcast_forecast_west', 'forecasts')|selectattr('period_end','gt',utcnow().isoformat())|map(attribute='pv_estimate')|list %}
{%- set solcast_east_list = state_attr('sensor.solcast_forecast_east', 'forecasts')|selectattr('period_end','gt',utcnow().isoformat())|map(attribute='pv_estimate')|list %}
{%- set values_all = namespace(all=[]) %}
{% for i in range(solcast_west_list | length) %}
{%- set v = ((solcast_west_list[i] + solcast_east_list[i]) | float |multiply(1000) ) | int(0) %}
{%- set values_all.all = values_all.all + [ v ] %}
{%- endfor %} {{ ([states('sensor.APF_Generation_Entity')|int(0)] + (values_all.all)[1:48]) }}
post_mpc_optim: "curl -i -H \"Content-Type: application/json\" -X POST -d '{\"load_cost_forecast\":{{(
([states('sensor.amber_general_price')|float(0)] +
state_attr('sensor.amber_general_forecast', 'forecasts') |map(attribute='per_kwh')|list)[:48])
}}, \"prod_price_forecast\":{{(
([states('sensor.amber_feed_in_price')|float(0)] +
state_attr('sensor.amber_feed_in_forecast', 'forecasts')|map(attribute='per_kwh')|list)[:48])
}}, \"pv_power_forecast\":{{states('sensor.solcast_24hrs_forecast')
}}, \"prediction_horizon\":{{min(48,
(state_attr('sensor.amber_feed_in_forecast', 'forecasts')|map(attribute='per_kwh')|list|length)+1)
}},\"alpha\":0, \"beta\":1, \"soc_init\":{{(states('sensor.powerwall_charge')|float(0))/100
}}, \"soc_final\":0.05, \"def_total_hours\":[{{states('sensor.def_total_hours_pool_filter')
}},{{states('sensor.def_total_hours_pool_heatpump')
}},{{states('sensor.def_total_hours_ev')
}},{{states('sensor.def_total_hours_hvac')
}},{{states('sensor.def_total_hours_hws')
}}]}' http://localhost:5000/action/naive-mpc-optim"
from emhass.
@davidusb-geek
You can use all my config
from emhass.
Thanks! I just added a complete new example to fusion two sensors to the documentation.
from emhass.
Related Issues (20)
- logging significantly reduced with 0.4.0 HOT 3
- Solar.Forecast service gives error HOT 1
- SSL Error SSLCertVerificationError HOT 1
- How to create a deferrable load sensor HOT 2
- Feature Request: Color for PV HOT 2
- Feature Request: smooth allocation of power to continuous loads HOT 6
- Feature Request: Some questions HOT 8
- Feature Request: Build in some priority HOT 1
- UnicodeDecodeError HOT 4
- prod_cost not updated.
- prod/load_cost unit_of_measurement €/kWh & $/kWh HOT 3
- Feature Request: unit_prod_price & unit_load_cost forecasts HOT 14
- Feature Request: Pass an array of hourly load_peak_hours costs instead of a constant value ( ex. prices from Tibber) HOT 2
- Solar forcast is broken HOT 3
- Feature request: Grid availability HOT 1
- 'last_window' has missing values error after HASS restart HOT 3
- Add single configuration to prefix all published sensors HOT 8
- When using the custom names there are no attributes is the sensors HOT 2
- Feature request - pass current battery SOC to dayahead-optim to improve optimization HOT 4
- Feature Request: First power deferrable loads from battery then discharge to grid. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emhass.