i don t get it runing.
i have this error all the time:
2023-11-29 05:36:55.402 ERROR (MainThread) [homeassistant.components.automation.awtrix_weather_forecast] Error rendering variables: UndefinedError: homeassistant.helpers.template.Wrapper object has no element 8
my config is this:
alias: AWTRIX Weather ⛈️ + Forecast + 🌕️
description: neuer versuch
use_blueprint:
path: jeeftor/awtrix_weatherflow.yaml
input:
awtrix:
- c1bc8b9997fe44faa85bb5b4dbeb28ca
forecast_var: weather.openweathermap
temp_suffix: °C
current_temp_var: sensor.openweathermap_feels_like_temperature
moon: sensor.moon
moon_rise_set: sensor.ip_geo_location
when_show_moon: never
how did you fix this problem?
i don t know why but no it is running. i played around with the values and now the automation is running.
i think some value was not really set but all fields were filled with text
jeeftor
(Jeef)
November 29, 2023, 10:56pm
44
Hey guys … unfortunately this one is a little lower on my priority list at the moment - Im currently working on a refactor of the IntelliFire integration but … The best advice I have is to look at the logs. One issue could be your weather provider. What are you guys using?
Hello, I have some basic questions on how to get this setup and working. Is the Discord still up and running? I tried joining and it said there are no chats available to me.
I’m a blueprint newbie. I set up all of the pre-requisites and see all of that as options to select in the blueprint. My question is, how to do ‘fire off’ this blueprint as an automation? I imported blueprint, created automation from it and entered in all of my information, but I never see it fire off.
MQTT is set up on my Awtrix flashed Ulanzi and I can test MQTT works by sending a test message from Home Assistant to the clock.
I can’t find a single Youtube video running thru setup and creation of this. I also uploaded the ‘Assets’ to the icons folder of my Ulanzi clock. I did enter in the moon stuff into my configuration.yaml file. After reboot, I’m able to select it within the blueprint. All seems well, just can’t understand why it doesn’t fire off…
Are there some helpers I need to create to get this to work?
I wonder if there is additional step I needed to take, what is this flow thing?
I had that red outline as well.
I restarted my Awtrix device and now the weather blueprint isn’t working at all.
The error I get is:
Logger: homeassistant.components.automation.awtrix_weather
Source: components/automation/__init__.py:604
Integration: Automation (documentation, issues)
First occurred: December 6, 2023 at 12:57:07 PM (12074 occurrences)
Last logged: 5:36:45 AM
Error rendering variables: JSONDecodeError: Input must be bytes, bytearray, memoryview, or str: line 1 column 1 (char 0)
Any thoughts?
brom
(Ben)
December 7, 2023, 3:12pm
47
I’m having the same issue. Looks like it broke with the latest home assistant upgrade to 2023.12.0
Not sure if others have seen the same thing.
(Mine has been working awesome for many months up until I upgraded to version 12)
Same here - the automation is broken after the upgrade to 2023.12. While I tried to debug the error I noticed that besides the error message (the same one @johnsturgeon is seeing) it appears that the REST sensor for moon rise/set is no longer updating, but I can’t say if that is related or not…
10der
(Oleg Denisenko)
December 7, 2023, 8:05pm
49
remove line
color_matrix_json: >-
{"-12": "#D977DF","-6": "#9545BC","-1": "#4B379C","0": "#FEC4FF","4":
"#31B8DB","10": "#31DB8B","15": "#6ED228","21": "#FFFF28","27":
"#F87E27","32": "#CF3927","38": "#A12527"}
change the next line like:
color_dict: >-
{%
set color_matrix_json = {
"-12": "#D977DF",
"-6": "#9545BC",
"-1": "#4B379C",
"0": "#FEC4FF",
"4": "#31B8DB",
"10": "#31DB8B",
"15": "#6ED228",
"21": "#FFFF28",
"27": "#F87E27",
"32": "#CF3927",
"38": "#A12527"
}
%}
{%
set b = color_matrix_json %} {%- set ns =
namespace(tuples=[]) %} {%- for k,v in b | items -%}
{%- set key = k|float -%}
{%- set ns.tuples = ns.tuples + [(key,v)] %}
{% endfor %} {{ dict.from_keys(ns.tuples) }}
for devs:
{%
set color_matrix_json = {"foo": "bar"}
%}
{%
set x = color_matrix_json | from_json
%}
{{x}}
JSONDecodeError: Input must be bytes, bytearray, memoryview, or str: line 1 column 1 (char 0)
but
{%
set color_matrix_json = '{"foo":"bar"}'
%}
{%
set x = color_matrix_json | from_json
%}
{{x}}
2 Likes
jpleite
December 8, 2023, 12:31pm
50
Hi @10der . Saw your post and deleted the line bellow from my automation (section Color Matrix)
color_matrix_json: >-
{"-12": "#D977DF","-6": "#9545BC","-1": "#4B379C","0": "#FEC4FF","4":
"#31B8DB","10": "#31DB8B","15": "#6ED228","21": "#FFFF28","27":
"#F87E27","32": "#CF3927","38": "#A12527"}
However, it is not clear where should I change the line you mention on point number 2. Is it on the blueprint?
Thanks
10der
(Oleg Denisenko)
December 8, 2023, 12:33pm
51
sorry. I used the own version. let me check the actual script version.
5 min!
jpleite
December 8, 2023, 12:48pm
53
Works now with your changed bluprint. Thank you very much from the fast help!!
1 Like
jeeftor
(Jeef)
December 8, 2023, 3:03pm
54
I still think something fundamental is wrong. I did some debugging this morning and the main issue is that for some reason Home Assistant thinks that the text is not a string and so it can’t turn it into json. Even though it is a string because if you asked the template agent to report what it is, it says it’s a string…
I think I found the bug:
opened 03:19PM - 08 Dec 23 UTC
### The problem
In upgrading from 2023.11 to 2023.12 I found that one of my b… lueprints was no longer working. Previously I had the user input JSON text and I could use `from_json` on it.
![image](https://github.com/home-assistant/core/assets/6491743/f9532c50-4543-4501-8495-a7b885bb382f)
![image](https://github.com/home-assistant/core/assets/6491743/fcd259d6-d877-4522-afdf-56ca22c86acb)
![image](https://github.com/home-assistant/core/assets/6491743/e74f64c8-f01b-404a-be41-56e92e501080)
I created a blueprint:
```yaml
---
blueprint:
name: JSON Issue Dev Blueprint
description: >
Trying to debug some issues
domain: automation
input:
color_matrix_json:
name: Color Matrix
description: >
Sample to show the problem
selector:
text:
multiline: true
default: >
{
"0": "#FEC4FF",
"10": "#D977DF",
"20": "#9545BC",
"30": "#4B379C",
"40": "#31B8DB",
"50": "#31DB8B",
"60": "#6ED228",
"70": "#FFFF28",
"80": "#F87E27",
"90": "#CF3927",
"100": "#A12527"
}
mode: restart
variables:
raw: >-
{% set json_text = {"0": "#FEC4FF","10": "#D977DF","20": "#9545BC","30": "#4B379C","40": "#31B8DB","50": "#31DB8B","60": "#6ED228","70": "#FFFF28","80": "#F87E27","90": "#CF3927","100": "#A12527"} %}
Mapping: {{ json_text is mapping }}
Str: {{ json_text is string }}
color_matrix: !input color_matrix_json
v2: >-
{% set json_text = color_matrix %}
Mapping: {{ json_text is mapping }}
Str: {{ json_text is string }}
v3: >-
{% set json_text = color_matrix %}
{{ json_text | from_json }}
trigger:
- platform: time_pattern
seconds: /5
condition: []
action:
[]
```
And specifically when it tries to run the
`{{ json_text | from_json }}`
It raises the JSON decoding error.
If I patch the code accordingly:
![image](https://github.com/home-assistant/core/assets/6491743/9489975d-ed69-4e02-8595-8d871c72b72e)
everything seems to work fine
### What version of Home Assistant Core has the issue?
core-2024.1.0.dev0
### What was the last working version of Home Assistant Core?
core-2023.11
### What type of installation are you running?
Home Assistant OS
### Integration causing the issue
_No response_
### Link to integration documentation on our website
_No response_
### Diagnostics information
_No response_
### Example YAML snippet
```yaml
---
blueprint:
name: JSON Issue Dev Blueprint
description: >
Trying to debug some issues
domain: automation
input:
color_matrix_json:
name: Color Matrix
description: >
Sample to show the problem
selector:
text:
multiline: true
default: >
{
"0": "#FEC4FF",
"10": "#D977DF",
"20": "#9545BC",
"30": "#4B379C",
"40": "#31B8DB",
"50": "#31DB8B",
"60": "#6ED228",
"70": "#FFFF28",
"80": "#F87E27",
"90": "#CF3927",
"100": "#A12527"
}
mode: restart
variables:
raw: >-
{% set json_text = {"0": "#FEC4FF","10": "#D977DF","20": "#9545BC","30": "#4B379C","40": "#31B8DB","50": "#31DB8B","60": "#6ED228","70": "#FFFF28","80": "#F87E27","90": "#CF3927","100": "#A12527"} %}
Mapping: {{ json_text is mapping }}
Str: {{ json_text is string }}
color_matrix: !input color_matrix_json
v2: >-
{% set json_text = color_matrix %}
Mapping: {{ json_text is mapping }}
Str: {{ json_text is string }}
v3: >-
{% set json_text = color_matrix %}
{{ json_text | from_json }}
trigger:
- platform: time_pattern
seconds: /5
condition: []
action:
[]
```
### Anything in the logs that might be useful for us?
```txt
2023-12-08 08:17:49.750 ERROR (MainThread) [homeassistant.components.automation.json_issue_dev_blueprint] Error rendering variables: JSONDecodeError: Input must be bytes, bytearray, memoryview, or str: line 1 column 1 (char 0)
```
### Additional information
- was noticed here in the forums after the upgrade: https://community.home-assistant.io/t/awtrix-lite-mega-weather-sunrise-moonrise/577515/48?u=jeeftor
If I try this directly in the template editor I dont seem to get the same problem:
If I comment out the `v3` portion of my blueprint it will run and prints out the info here:
```
v2: 'Mapping: False Str: True'
```
So although it is reporting that the value is a `string` it appears in `template.py` we can't handle `NodeStrClass` in the from_json function
jeeftor
(Jeef)
December 8, 2023, 3:51pm
55
home-assistant:dev
← home-assistant:orjson_derived_class_workaround
opened 03:49PM - 08 Dec 23 UTC
<!--
You are amazing! Thanks for contributing to our project!
Please, DO N… OT DELETE ANY TEXT from this template! (unless instructed).
-->
## Proposed change
<!--
Describe the big picture of your changes here to communicate to the
maintainers why we should accept this pull request. If it fixes a bug
or resolves a feature request, be sure to link to that issue in the
additional information section.
-->
Add workaround for `orjson` not handling subclasses of str
Fixes https://github.com/home-assistant/core/issues/105309
Reported on orjson as https://github.com/ijl/orjson/issues/445
## Type of change
<!--
What type of change does your PR introduce to Home Assistant?
NOTE: Please, check only 1! box!
If your PR requires multiple boxes to be checked, you'll most likely need to
split it into multiple PRs. This makes things easier and faster to code review.
-->
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [ ] New feature (which adds functionality to an existing integration)
- [ ] Deprecation (breaking change to happen in the future)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
## Additional information
<!--
Details are important, and help maintainers processing your PR.
Please be sure to fill out additional details, if applicable.
-->
- This PR fixes or closes issue: fixes #
- This PR is related to issue:
- Link to documentation pull request:
## Checklist
<!--
Put an `x` in the boxes that apply. You can also fill these out after
creating the PR. If you're unsure about any of them, don't hesitate to ask.
We're here to help! This is simply a reminder of what we are going to look
for before merging your code.
-->
- [ ] The code change is tested and works locally.
- [ ] Local tests pass. **Your PR cannot be merged unless tests pass**
- [ ] There is no commented out code in this PR.
- [ ] I have followed the [development checklist][dev-checklist]
- [ ] I have followed the [perfect PR recommendations][perfect-pr]
- [ ] The code has been formatted using Ruff (`ruff format homeassistant tests`)
- [ ] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated for [www.home-assistant.io][docs-repository]
If the code communicates with devices, web services, or third-party tools:
- [ ] The [manifest file][manifest-docs] has all fields filled out correctly.
Updated and included derived files by running: `python3 -m script.hassfest`.
- [ ] New or updated dependencies have been added to `requirements_all.txt`.
Updated by running `python3 -m script.gen_requirements_all`.
- [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
- [ ] Untested files have been added to `.coveragerc`.
<!--
This project is very active and we have a high turnover of pull requests.
Unfortunately, the number of incoming pull requests is higher than what our
reviewers can review and merge so there is a long backlog of pull requests
waiting for review. You can help here!
By reviewing another pull request, you will help raise the code quality of
that pull request and the final review will be faster. This way the general
pace of pull request reviews will go up and your wait time will go down.
When picking a pull request to review, try to choose one that hasn't yet
been reviewed.
Thanks for helping out!
-->
To help with the load of incoming pull requests:
- [ ] I have reviewed two other [open pull requests][prs] in this repository.
[prs]: https://github.com/home-assistant/core/pulls?q=is%3Aopen+is%3Apr+-author%3A%40me+-draft%3Atrue+-label%3Awaiting-for-upstream+sort%3Acreated-desc+review%3Anone+-status%3Afailure
<!--
Thank you for contributing <3
Below, some useful links you could explore:
-->
[dev-checklist]: https://developers.home-assistant.io/docs/development_checklist/
[manifest-docs]: https://developers.home-assistant.io/docs/creating_integration_manifest/
[quality-scale]: https://developers.home-assistant.io/docs/integration_quality_scale_index/
[docs-repository]: https://github.com/home-assistant/home-assistant.io
[perfect-pr]: https://developers.home-assistant.io/docs/review-process/#creating-the-perfect-pr
Use the hacks for now … or … wait for the next update
1 Like
jeeftor
(Jeef)
December 8, 2023, 7:47pm
56
I just downgraded to 2023.11 because the upgrade also broke entity_controller
brom
(Ben)
December 9, 2023, 9:54am
57
HA 2023.12.1 is now out and it seems the issue is fixed.
jeeftor
(Jeef)
December 9, 2023, 2:10pm
58
Thanks for bugging me here as i was able to identify the bug and they got a quick fix out
samcgn
(Sam)
December 9, 2023, 11:56pm
59
Hi,
the automation never gets executed. I use Homeassistant 2023.12.1 on HA green. Error log shows:
Logger: homeassistant.components.automation.awtrix_weather_forecast
Source: components/automation/init .py:604
Error rendering variables: ValueError: Template error: float got invalid input 'unknown' when rendering template '{%- macro interpolate(dictionary, x) -%} {%- set sorted_keys = dictionary|dictsort -%} {%- set above = sorted_keys|selectattr('0', 'gt', x)|map(attribute='0')|list|first -%} {%- set below = sorted_keys|selectattr('0', 'lt', x)|map(attribute='0')|list|last -%} {#- Key matches x exactly -#} {%- if above is defined and dictionary[above] == x -%} {%- set value = dictionary[above] -%} {{ value }} {%- elif below is defined and dictionary[below] == x -%} {%- set value = dictionary[below] -%} {{ value }} {#- Interpolation between two values -#} {%- elif below is defined and above is defined -%} {%- set lower_value = dictionary[below] -%} {%- set upper_value = dictionary[above] -%} {%- set lower_rgb = lower_value[1:] -%} {%- set upper_rgb = upper_value[1:] -%} {%- set lower_r = lower_rgb[0:2]|int(base=16) -%} {%- set lower_g = lower_rgb[2:4]|int(base=16) -%} {%- set lower_b = lower_rgb[4:6]|int(base=16) -%} {%- set upper_r = upper_rgb[0:2]|int(base=16) -%} {%- set upper_g = upper_rgb[2:4]|int(base=16) -%} {%- set upper_b = upper_rgb[4:6]|int(base=16) -%} {%- set interpolation_factor = (x - below) / (above - below) -%} {%- set interpolated_r = ((1 - interpolation_factor) * lower_r + interpolation_factor * upper_r)|int -%} {%- set interpolated_g = ((1 - interpolation_factor) * lower_g + interpolation_factor * upper_g)|int -%} {%- set interpolated_b = ((1 - interpolation_factor) * lower_b + interpolation_factor * upper_b)|int -%} {%- set interpolated_hex = '#' ~ '%02X' % interpolated_r ~ '%02X' % interpolated_g ~ '%02X' % interpolated_b -%} {{ interpolated_hex }} {#- Only below key available -#} {%- elif below is defined -%} {%- set value = dictionary[below] -%} {{ value }} {#- Only above key available -#} {%- elif above is defined -%} {%- set value = dictionary[above] -%} {{ value }} {#- No matching keys available -#} {%- else -%} No matching key found. {%- endif -%} {%- endmacro -%} {#- Define macro to get length of the forecast} {%- macro str_len(str) %} {%- if '.' in str %} {%- set char_count = (str | length) -1 %}{{char_count * 3 + 1 + char_count}} {%- else %} {%- set char_count = (str | length) %}{{char_count * 3 + (char_count - 1)}} {%- endif %} {%- endmacro %} {#- Define a macro to draw out the forecast lines#} {%- macro draw_forecast_lines(x,hours,height) %} {%- for hour in range(hours) %} {%- if height == 0 %} {"dp": [{{x+hour}},7,"{{interpolate(color_dict, forecast[hour][forecast_temp_field]) }}"]} {%- else %} {"dl": [{{x+hour}},7,{{x+hour}},{{7 - height}},"{{interpolate(color_dict, forecast[hour][forecast_temp_field]) }}"]} {%- endif %} {%- if hour+1 != hours %},{%endif%} {%- endfor %} {%- endmacro %} {# Define the color mapping dictionary #} { "draw": [ {%- if hours_to_show > 0 %} {{draw_forecast_lines(8,hours_to_show,0)}} {%- endif %} {%- if current_temp != 'unavailable' -%} ,{"dt":[{{text_x}},1,"{{temp_text}}","{{interpolate(color_dict, current_temp | float)}}"]} {%- else -%} {"dt":"err"} {%- endif -%} {% if show_moon %} ,{{moon_data}} {% endif %} ], "icon": "{{icon}}", "duration": {{message_duration}}, "pushIcon": 2, "lifetime": 120, "lifetimeMode":1, "weather": "{{weather}}" }' but no default was specified
Perhaps it is possible to issue a simple version w/o moon nor sun, only for weather.
Thanks for your effort and dedication to this project,
-sam
1 Like
jeeftor
(Jeef)
December 11, 2023, 3:50pm
60
I need to write a debug guide for this stuff
1 Like