kloggy / HA-Irrigation-Version2

221 stars 55 forks source link

ButtonCardJSTemplateError in General setting #70

Open danygi79 opened 2 years ago

danygi79 commented 2 years ago

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 commented 2 years ago

What do you have in input_text.irrigation_external_sensor_controller_wifi?

danygi79 commented 2 years ago

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

danygi79 commented 2 years ago

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

kloggy commented 2 years ago

How do you control your valves?

What is the state of your input_text.irrigation_external_sensor_controller_wifi?

Bubino1964 commented 2 years ago

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

genestealer commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

Snag_18a52348
danygi79 commented 2 months ago

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