Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ButtonCardJSTemplateError in General setting #70

Open
danygi79 opened this issue Apr 7, 2022 · 10 comments
Open

ButtonCardJSTemplateError in General setting #70

danygi79 opened this issue Apr 7, 2022 · 10 comments

Comments

@danygi79
Copy link

danygi79 commented Apr 7, 2022

Hello, I have a problem in principal card and I don't understand why.

Schermata 2022-04-07 alle 22 20 40

I've searched everywhere but can't find a way to fix this problem.

@kloggy
Copy link
Owner

kloggy commented Apr 7, 2022

What do you have in input_text.irrigation_external_sensor_controller_wifi?

@danygi79
Copy link
Author

danygi79 commented Apr 8, 2022

no, I didn't understand where it should be set

@danygi79
Copy link
Author

danygi79 commented Apr 8, 2022

I have no controller connected in wifi, I cannot set any value

@kloggy
Copy link
Owner

kloggy commented Apr 8, 2022

How do you control your valves?

What is the state of your input_text.irrigation_external_sensor_controller_wifi?

@Bubino1964
Copy link

Hi,
I have same problem!
Sorry Kloggy but I didn't understand your instruction!

@genestealer
Copy link

genestealer commented Apr 18, 2022

@kloggy
I had a similar problem, but I think I may have found the root of the problem: It's in the automation "\packages\garden_irrigation\irrigation_controller.yaml" "irrigation_set_default_controller_wifi_signal_sensor" which is setting the default controller Wi-Fi signal sensor value, to a sensor that does not exist within other configurations.

"input_text.irrigation_external_sensor_controller_wifi" set to "sensor.esphome_irrigation_controller_wifi_signal" if "irrigation_external_sensor_controller_wifi" is unknown or blank.

image

It seems that you are setting this value to "sensor.esphome_irrigation_controller_wifi_signal", which in my case I do not have. (I also assume this is the case for others, as it's not listed as a prerequisite). However a quick search shows it's used throughout your code, such as for Wi-Fi interruption notification.

Therefore the code you have in "\lovelace\garden_irrigation\settings\general\item_settings_controller_wifi_signal.yaml" to check to see if the state is undefined is never triggered, as you're always setting it to a state on boot, or if the entities ever set to 'blank' ('').

This produces the error "ButtonCardJSTemplateError: TypeError: Cannot read properties of undefined (reading 'state') in 'var statestr = (entity === undefined || entity.state === undefined) ? 'undefined' : entity.state;"

image

Which, if you refresh the webpage, causes the entire button to disappear.
image

I tested this theory by commenting out the code that does the checks, which did indeed bring back the pop-up button.
image

In summary, the checks you have in place to see if the entity is undefined, in "item_settings_controller_wifi_signal.yaml" are resulting in a error, as the entity is being defined to a predefined entity, by an automation, upon each boot.
image

@genestealer
Copy link

genestealer commented Apr 18, 2022

There's definitely something not quite right with "item_settings_controller_wifi_signal.yaml".

If you accidentally sent the value of "input_text.irrigation_external_sensor_controller_wifi" to a invalid state, such as an entity that does not exist, or a typographical error, the custom button card will just disappear.

image

Induce an error
image

Button disappears.
image

Open the page on a new tab and you get the common error:
image

@genestealer
Copy link

A quick and dirty solution to fix this issue for anyone else having a problem

In the file: "\lovelace\garden_irrigation\settings\general\item_settings_controller_wifi_signal.yaml"

Edit the 'name' and 'icon' lines to just state:

name: "Controller"
icon: mdi:wifi

image

@Bubino1964
Copy link

Hi genestealer
thanks for your help!
Now I have same problem with "NEXT RUN: " ! :(
Snag_18a52348

@danygi79
Copy link
Author

After following your advice I also have the same problem as Bubin1964. Does anyone have a suggestion on how to fix it?

Thank's to all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants