This will be populated soon
edwardtfn / homeassistant-config Goto Github PK
View Code? Open in Web Editor NEWEdward Firmo's Home Assistant config files
License: MIT License
Edward Firmo's Home Assistant config files
License: MIT License
Hello,
First of all I wanted to thank you for the grate work an the idea to plot those data!
not sure if it is wrong, cause I am not familiar with all those YAML and Plotty.
However I found out that this line for the Lovelace Card did not work in my configuration:
xs: [vars.electricity_price.xs.slice(-1)[0],...meta.future_prices.map(({ startsAt }) => new Date(startsAt))]
It is just becuause the tibber.yaml doesnt write future_prices
instead it ist just future
in the sensor.
Do I miss something here?
Anyway after fixing meta.future.map everything was working (until i figured out that for the Past energy prices I have to use a Sensor which is in my database).
hello blueprint dont't update hassio and module why ?
template:
{% for u in integration_entities('hassio') | select('search', '^update[.]')
if (device_attr(u, 'identifiers') | first)[1] == 'OS' %}
{{ u }}
{% endfor %}
give result:
update.home_assistant_operating_system_update
This model does not listen for any state change events and will not be updated automatically.
and:
{{ states.update | selectattr('state','eq','on') | map(attribute='entity_id') | list }}
give:
update.home_assistant_operating_system_update
['update.home_assistant_core_update', 'update.wallbox_firmware']
This model listens for the following state change events:
Domain: update
This is related to the blueprint: auto_update_scheduled.yaml
Hi, Thank you for creating the blueprint. I highly appreciate the efforts in creating it.
I created automation based on the blueprint. It is triggered, but it is not running.
It is stopped at the 3rd condition.
When checking the traces (see below), I believe the trigger status is swapped. It is from "on" to "off". Should it not be from "off" to ''on"?
How can this be changed? Is this something that needs to be updated in the blueprint?
Best, Sebastian
this:
entity_id: automation.auto_update_home_assistant_on_a_schedule_base
state: 'on'
attributes:
last_triggered: '2023-03-09T08:00:00.011443+00:00'
mode: single
current: 1
id: '1678241096997'
friendly_name: Update_Auto Home Assistant on a schedule base
last_changed: '2023-03-08T15:17:58.497737+00:00'
last_updated: '2023-03-09T08:00:00.011657+00:00'
context:
id: 01GV2P4M06X5FS3YBZZA2KV825
parent_id: 01GV2P4M010K7XBKQWAXQ86WB9
user_id: null
trigger:
id: HA Schedule based
idx: '0'
alias: null
platform: state
entity_id: schedule.auto_update_schedule
from_state:
entity_id: schedule.auto_update_schedule
state: 'on'
attributes:
editable: true
next_event: '2023-03-09T03:30:00-05:00'
friendly_name: Auto_Update_Schedule
last_changed: '2023-03-09T08:00:00.001905+00:00'
last_updated: '2023-03-09T08:00:00.001905+00:00'
context:
id: 01GV2P4M010K7XBKQWAXQ86WB9
parent_id: null
user_id: null
to_state:
entity_id: schedule.auto_update_schedule
state: 'off'
attributes:
editable: true
next_event: '2023-03-10T03:00:00-05:00'
friendly_name: Auto_Update_Schedule
last_changed: '2023-03-09T08:30:00.002221+00:00'
last_updated: '2023-03-09T08:30:00.002221+00:00'
context:
id: 01GV2QVHT2HKT4C7YD7NDAW0NH
parent_id: null
user_id: null
for: null
attribute: null
description: state of schedule.auto_update_schedule
input_schedule_monthday: 1
input_pause_entities: []
temp_input_update_exclusions: []
input_update_exclusions: []
The automation "auto update HA" (automation.auto_update_ha) has an action that calls an unknown service: hassio.host_reboot.
The same goes for backup, different command in Core version.
Hi Edward,
Getting an error while running the automation based on your blueprint.
Used to be running fine, but since updating to HA 2023.4 I’m getting this error:
Let me know if you need anything more.
Logger: homeassistant.components.automation.home_assistant_auto_update_on_a_schedule_base
Source: components/automation/__init__.py:254
Integration: Automatisering ([documentation](https://www.home-assistant.io/integrations/automation), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+automation%22))
First occurred: 10:24:02 (1 occurrences)
Last logged: 10:24:02
Error while executing automation automation.home_assistant_auto_update_on_a_schedule_base: AwesomeVersionCompareException: Not a valid AwesomeVersion object
Logger: homeassistant.components.automation.home_assistant_auto_update_on_a_schedule_base
Source: helpers/script.py:410
Integration: Automatisering (documentation, issues)
First occurred: 10:24:02 (1 occurrences)
Last logged: 10:24:02
Home Assistant Auto-update on a schedule base: Error executing script. Error rendering template for variables at pos 1: AwesomeVersionCompareException: Not a valid AwesomeVersion object
Hey Edward,
since I am totally unexperienced in programming I had to use "copy-paste" and "try-and-error" for integrating the tibber price graphs into HA.
I only used your rest-sensor:
sensor:
# https://community.home-assistant.io/t/tibber-sensor-for-future-price-tomorrow/253818/23
- platform: rest
name: Tibber Electricity Price
resource: https://api.tibber.com/v1-beta/gql
method: POST
scan_interval: 900
payload: '{ "query": "{ viewer { homes { currentSubscription { priceInfo { current { total currency level } today { total startsAt level } tomorrow { total startsAt level }}}}}}" }'
json_attributes_path: "$.data.viewer.homes[0].currentSubscription.priceInfo"
json_attributes:
- current
- today
- tomorrow
value_template: '{{ value_json["data"]["viewer"]["homes"][0]["currentSubscription"]["priceInfo"]["current"]["total"] }}'
headers:
Authorization: !secret tibber_api_token
Content-Type: application/json
User-Agent: REST
It also states "Cheap, normal and expensive".
Now I wonder if it is possible to create a line or bar chart with the different colors for it.
E.g. cheap=green, normal=yellow and expensive=red and/or a sensor which states the times with the cheapest prices maybe like this:
"Cheapest today: 01:00:00 - 02:00:00
15:00:00 - 16:00:00"
"Cheapest tomorrow: 07:00:00 - 08:00:00"
Do you think it is possible to create something like this?
THANKS so far!
Hi @edwardtfn,
is the "Electricy price" template sensor as you have it specified here still supposed to work?
I copied it as is but unfortunately the sensor is "Unavailable" for me:
even though the "Tibber Electricity Price" REST sensor works just fine?
Is there anything I am missing or doing wrong? The YAML files are below, if you could maybe take a quick look?
Thanks so much!
The "Tibber Electricity Price" sensor looks like this:
- sensor:
- platform: rest
name: Tibber Electricity Price
unique_id: <a-unique-id>
icon: mdi:currency-eur
resource: https://api.tibber.com/v1-beta/gql
method: POST
scan_interval: 60
payload: '{ "query": "{ viewer { homes { currentSubscription { priceInfo { current { total currency level } today { total startsAt level } tomorrow { total startsAt level }}}}}}" }'
json_attributes_path: "$.data.viewer.homes[0].currentSubscription.priceInfo"
json_attributes:
- current
- today
- tomorrow
value_template: '{{ value_json["data"]["viewer"]["homes"][0]["currentSubscription"]["priceInfo"]["current"]["total"] }}'
headers:
Authorization: <secret>
Content-Type: application/json
User-Agent: REST
The "Electricity Price" sensor looks like this:
- template:
- sensor:
- name: Electricity Price
unique_id: <a-unique-id>
unit_of_measurement: "€/kWh"
icon: mdi:currency-eur
state: >-
{% if this.attributes.future_prices | default('unknown') in ['unknown', 'unavailable'] or (this.attributes.future_prices | default([]) | map(attribute='total') | list | count) < 1 %}
unknown
{% else %}
{{ this.attributes.future_prices | default([]) | map(attribute='total') | list | first | float(0) }}
{% endif %}
attributes:
current: >-
{% if state_attr('sensor.tibber_electricity_price', 'current') %}
{{ state_attr('sensor.tibber_electricity_price', 'current') }}
{% else %}
[ ]
{% endif %}
today: >-
{% if state_attr('sensor.tibber_electricity_price', 'today') %}
{{ state_attr('sensor.tibber_electricity_price', 'today') }}
{% else %}
[ ]
{% endif %}
tomorrow: >-
{% if state_attr('sensor.tibber_electricity_price', 'tomorrow') %}
{{ state_attr('sensor.tibber_electricity_price', 'tomorrow') }}
{% else %}
[ ]
{% endif %}
all_prices: "{{ this.attributes.today | default([]) + this.attributes.tomorrow | default([]) }}"
#today_count: "{{ this.attributes.today | default([]) | map(attribute='total') | list | count }}"
#tomorrow_count: "{{ this.attributes.tomorrow | default([]) | map(attribute='total') | list | count }}"
#all_prices_count: "{{ this.attributes.all_prices | default([]) | map(attribute='total') | list | count }}"
min_price: >-
{% if this.attributes.today | default('unknown') in ['unknown','unavailable','none'] or (this.attributes.today | default([]) | map(attribute='total') | list | count) < 1 %}
unknown
{% else %}
{{ this.attributes.today | default([0]) | map(attribute='total') | list | min | float(0) | round(4) }}
{% endif %}
max_price: >-
{% if this.attributes.today | default('unknown') in ['unknown','unavailable','none'] or (this.attributes.today | default([]) | map(attribute='total') | list | count) < 1 %}
unknown
{% else %}
{{ this.attributes.today | default([0]) | map(attribute='total') | list | max | float(0) | round(4) }}
{% endif %}
avg_price: >-
{% if this.attributes.today | default('unknown') in ['unknown','unavailable','none'] or (this.attributes.today | default([]) | map(attribute='total') | list | count) < 1 %}
unknown
{% elif (this.attributes.today | default([]) | map(attribute='total') | list | count) < 2 %}
{{ this.attributes.today | default([0]) | map(attribute='total') | list | max | float(0) | round(4) }}
{% else %}
{{ this.attributes.today | default([0]) | map(attribute='total') | list | average(0) | float(0) | round(4) }}
{% endif %}
price_level: >-
{% if (this.attributes.current | default('unknown')) in ['unknown','unavailable','none'] %}
unknown
{% else %}
{{ this.attributes.current.level | default('unknown') | replace('_', ' ') | capitalize }}
{% endif %}
price_level_1d: >-
{% set price_cur = this.state | default(0) | float(0) %}
{% set price_avg = this.attributes.avg_price | default(0) | float(0) %}
{% if price_cur == 0 or price_avg == 0 %}
unknown
{% else %}
{% set price_ratio = (price_cur / price_avg) %}
{% if price_ratio >= 1.4 %}
Very expensive
{% elif price_ratio >= 1.15 %}
Expensive
{% elif price_ratio <= 0.6 %}
Very cheap
{% elif price_ratio <= 0.9 %}
Cheap
{% else %}
Normal
{% endif %}
{% endif %}
price_level_combined: >-
{% set level1 = this.attributes.price_level_1d | default('unknown') %}
{% set level3 = this.attributes.price_level | default('unknown') %}
{% if level1 == level3 %}
{{ level1 }}
{% elif level1 in ['unknown','unavailable','none'] or level3 in ['unknown','unavailable','none'] %}
unknown
{% elif level1 == "Very cheap" %}
{{ level3 }}
{% elif level3 == "Very cheap" %}
{{ level1 }}
{% elif level1 == "Cheap" %}
{{ level3 }}
{% elif level3 == "Cheap" %}
{{ level1 }}
{% elif level1 == "Normal" %}
{{ level3 }}
{% elif level3 == "Normal" %}
{{ level1 }}
{% elif level1 == "Expensive" %}
{{ level3 }}
{% else %}
{{ level1 }}
{% endif %}
is_below_average: >-
{% if is_number(this.state) and is_number(this.attributes.avg_price) %}
{{ (this.state | float(0) < this.attributes.avg_price | float(0)) | lower }}
{% else %}
unknown
{% endif %}
is_above_average: >-
{% if is_number(this.state) and is_number(this.attributes.avg_price) %}
{{ (this.state | float(0) > this.attributes.avg_price | float(0)) | lower}}
{% else %}
unknown
{% endif %}
is_at_min: >-
{% if is_number(this.state) and is_number(this.attributes.min_price) %}
{{ (this.state | float(0) <= this.attributes.min_price | float(0)) | lower }}
{% else %}
unknown
{% endif %}
is_at_max: >-
{% if is_number(this.state) and is_number(this.attributes.max_price) %}
{{ (this.state | float(0) >= this.attributes.max_price | float(0)) | lower }}
{% else %}
unknown
{% endif %}
is_close_to_min: >-
{% if is_number(this.state) and is_number(this.attributes.min_price) %}
{{ (this.state | float(0) <= (1.15 * this.attributes.min_price | float(0))) | lower }}
{% else %}
unknown
{% endif %}
future_prices: >-
{% if (this.attributes.all_prices | default('unknown')) in ['unknown','unavailable','none'] %}
unknown
{% else %}
{{ (this.attributes.all_prices | default([])) | selectattr('startsAt', 'gt', (now() - timedelta(hours=1)) | string | replace(' ','T')) | list }}
{% endif %}
future_prices_totals: >-
{% if (this.attributes.future_prices | default('unknown')) in ['unknown','unavailable','none'] %}
unknown
{% else %}
{{ (this.attributes.future_prices | default([])) | map(attribute='total') | list }}
{% endif %}
#future_prices_count: "{{ (this.attributes.future_prices_totals | default([])) | count }}"
future_prices_min: |-
{% if this.attributes.future_prices_totals | default([0]) | count > 0 %}
{{ this.attributes.future_prices_totals | default([0]) | min | float(0) | round(4) }}
{% else %}
unknown
{% endif %}
future_prices_max: |-
{% if this.attributes.future_prices_totals | default([0]) | count > 0 %}
{{ (this.attributes.future_prices_totals | default([0])) | max | float(0) | round(4) }}
{% else %}
unknown
{% endif %}
future_prices_avg: >-
{% if this.attributes.future_prices_totals | default([0]) | count > 0 %}
{{ (this.attributes.future_prices_totals | default([0])) | average(0) | float(0) | round(4) }}
{% else %}
unknown
{% endif %}
future_prices_curr_price_level: >-
{% set price_cur = this.state | default(0) | float(0) %}
{% set price_avg = this.attributes.future_prices_avg | default(0) | float(0) %}
{% if price_cur == 0 or price_avg == 0 %}
unknown
{% else %}
{% set price_ratio = (price_cur / price_avg) %}
{% if price_ratio >= 1.4 %}
Very expensive
{% elif price_ratio >= 1.15 %}
Expensive
{% elif price_ratio <= 0.6 %}
Very cheap
{% elif price_ratio <= 0.9 %}
Cheap
{% else %}
Normal
{% endif %}
{% endif %}
future_prices_16h: >-
{% if (this.attributes.future_prices | default('unknown')) in ['unknown','unavailable','none'] %}
unknown
{% else %}
{{ (this.attributes.future_prices | default([]) | list)[0:16]}}
{% endif %}
future_prices_16h_totals: >-
{% if (this.attributes.future_prices_16h | default('unknown')) in ['unknown','unavailable','none'] %}
unknown
{% else %}
{{ (this.attributes.future_prices_16h | default([])) | map(attribute='total') | list }}
{% endif %}
#future_prices_16h_count: "{{ (this.attributes.future_prices_16h_totals | default([])) | count }}"
future_prices_16h_min: |-
{% if this.attributes.future_prices_16h_totals | default([0]) | count > 0 %}
{{ (this.attributes.future_prices_16h_totals | default([0])) | min | float(0) | round(4) }}
{% else %}
unknown
{% endif %}
future_prices_16h_max: |-
{% if this.attributes.future_prices_16h_totals | default([0]) | count > 0 %}
{{ (this.attributes.future_prices_16h_totals | default([0])) | max | float(0) | round(4) }}
{% else %}
unknown
{% endif %}
future_prices_16h_avg: >-
{% if this.attributes.future_prices_16h_totals | default([0]) | count > 0 %}
{{ (this.attributes.future_prices_16h_totals | default([0])) | average(0) | float(0) | round(4) }}
{% else %}
unknown
{% endif %}
future_prices_16h_current_price_level: >-
{% set price_cur = this.state | default(0) | float(0) %}
{% set price_avg = this.attributes.future_prices_16h_avg | default(0) | float(0) %}
{% if price_cur == 0 or price_avg == 0 %}
unknown
{% else %}
{% set price_ratio = (price_cur / price_avg) %}
{% if price_ratio >= 1.4 %}
Very expensive
{% elif price_ratio >= 1.15 %}
Expensive
{% elif price_ratio <= 0.6 %}
Very cheap
{% elif price_ratio <= 0.9 %}
Cheap
{% else %}
Normal
{% endif %}
{% endif %}
future_prices_16h_current_price_is_close_to_min: >-
{% if is_number(this.state) and is_number(this.attributes.future_prices_16h_min) %}
{{ (this.state | float(0) <= (1.15 * this.attributes.future_prices_16h_min | default(0) | float(0))) | lower }}
{% else %}
unknown
{% endif %}
future_prices_16h_current_price_is_at_min: >-
{% if this.state | default(0) | float(0) > 0 and this.attributes.future_prices_16h_min | default(0) | float(0) > 0 %}
{{ (this.state | default(0) | float(0) <= this.attributes.future_prices_16h_min | default(0) | float(0)) | lower }}
{% else %}
unknown
{% endif %}
The error I am getting in the log is:
Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:509
Integration: Sensor (documentation, issues)
First occurred: 22:53:18 (1 occurrences)
Last logged: 22:53:18
Error adding entities for domain sensor with platform template
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 616, in state
numerical_value = int(value)
^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'unknown'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 619, in state
numerical_value = float(value)
^^^^^^^^^^^^
ValueError: could not convert string to float: 'unknown'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 509, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 754, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1024, in add_to_platform_finish
await self.async_added_to_hass()
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 537, in async_added_to_hass
async_at_start(self.hass, self._async_template_startup)
File "/usr/src/homeassistant/homeassistant/helpers/start.py", line 67, in async_at_start
return _async_at_core_state(
^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/start.py", line 32, in _async_at_core_state
hass.async_run_hass_job(at_start_job, hass)
File "/usr/src/homeassistant/homeassistant/core.py", line 671, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 478, in _async_template_startup
result_info.async_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1035, in async_refresh
self._refresh(None)
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1215, in _refresh
self.hass.async_run_hass_job(self._job, event, updates)
File "/usr/src/homeassistant/homeassistant/core.py", line 671, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 429, in _handle_results
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 745, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 845, in _async_write_ha_state
state, attr = self._async_generate_attributes()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 786, in _async_generate_attributes
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 751, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 623, in state
raise ValueError(
ValueError: Sensor sensor.electricity_price has device class 'None', state class 'None' unit '€/kWh' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'unknown' (<class 'str'>)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.