joBr99 / nspanel-lovelace-ui

Custom Firmware for NsPanel with the design of HomeAssistant's lovelace UI in mind, works with Tasmota.
GNU General Public License v3.0
854 stars 187 forks source link

[BUG] Weather card no longer works in HA 2024.4 #1204

Closed tetele closed 3 months ago

tetele commented 3 months ago

PROBLEM DESCRIPTION

The weather card used as a screensaver cannot display anything when connected to HA 2024.4.0b0 due to the removal of the forecast attribute for weather entities. It worked well in 2024.3.

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

- [ ] Go to Settings>Add-ons>AppDaemon>Log (or the output of your TS script) and then, provide the output of the log during your issue/bug occurs:

Log output here:

irrelevant



### TO REPRODUCE
Install HA 2024.4 beta and look at the NSPanel

### EXPECTED BEHAVIOUR
_A clear and concise description of what you expected to happen._

### SCREENSHOTS
_If applicable, add screenshots/pictures to help explain your problem._

### ADDITIONAL CONTEXT
_Add any other context about the problem here._
_Please note here in case you are using ioBroker_

### PANEL / FIRMWARE VERSION
_Please add the Panel/Firmware Version you are using (EU, US-L or US-P)_
EU panel, Tasmota 13.4.0, HA 2024.4 beta
joBr99 commented 3 months ago

Thanks for the heads-up, will try to fix this over the weekend.

Unfortunately this is still blocked by upstream, but it looks like there is now a workaround.

https://github.com/AppDaemon/appdaemon/issues/1837

joBr99 commented 3 months ago

@Odianosen25 Hey, can you help me out with this, not entirely sure how to implement that workaround as it's using async stuff.

joBr99 commented 3 months ago

came up with a different workaround to keep home assistant providing the forecast as an entity

https://docs.nspanel.pky.eu/stable/prepare_ha/#workaround-for-homeassistant-202404

This also requires two slight changes in the backed to force the entity type of this newly created sensor to weather. So it also requires an update of the backend to current dev version.

(or you just do those two changes manually) https://github.com/joBr99/nspanel-lovelace-ui/commit/d94d937d776c9ca9dd5cf083c54fc4c51d02af5f https://github.com/joBr99/nspanel-lovelace-ui/commit/e5c1f0588a3dfc226f129c822bfa83571fd2d240

joBr99 commented 3 months ago

Released the changes in 4.4.0

For anyone updating please note that you need to have app_dir in your appdaemon.yaml for HACS to be working, see #1029

tetele commented 3 months ago

Thank you!

tetele commented 3 months ago

Something's a bit off. I'll debug when i have the time, but just letting you know @joBr99

20240401_173504

joBr99 commented 3 months ago

looks like the entity you specified in your config doesn't exist

tetele commented 3 months ago

Right. I forgot to change the domain from weather to sensor, but even after changing it it has some issues

20240401_181157

joBr99 commented 3 months ago

don't change the first entity - also there's something wrong with your update to the latest version of the appdaemon app - either you forgot to restart appdaemon or you didn't follow all steps during the appdaemon 15 update and you are still accessing an old copy of the app https://github.com/joBr99/nspanel-lovelace-ui/issues/1029

tetele commented 3 months ago

What I did was name the sensor differently and NOT add that name in the overrides you mentioned. Sorry, I was super tired yesterday and not able to pay attention to what I was doing.

I still have an issue with the current weather condition (it's not showing), but I'll debug that one myself. Thanks a lot for your help and swiftness!

tetele commented 3 months ago

Your template sensor needs a proper state and a temperature attribute @joBr99 , otherwise the current condition will look like this

20240402_173004

The full template i used is this:

template:
  - trigger:
      - platform: time_pattern
        hours: /1
    action:
      - service: weather.get_forecasts
        data:
          type: daily
        target:
          entity_id: weather.home
        response_variable: daily
    sensor:
      - name: Weather Forecast Daily
        unique_id: weather_forecast_daily
        state: "{{ states('weather.home') }}"
        attributes:
          temperature: "{{ state_attr('weather.home', 'temperature') }}"
          temperature_unit: "{{ state_attr('weather.home', 'temperature_unit') }}"
          forecast: "{{ daily['weather.home'].forecast }}"

Note that you can't trigger a manual update for the sensor, you have to either wait for XX:00 or add other triggers.

joBr99 commented 3 months ago

I just used the normal weather entity for the for the current condition, as this isn't part of the forecast and the workaround is only required for the forecast. (Thanks for the template, might be a good idea to exchange the one in the documentation, to avoid confusion)

tetele commented 3 months ago

I was not aware you can have one entity for current condition and another for forecast.

joBr99 commented 3 months ago

You can configure each item individually:

    screensaver:
      entities:
        - entity: weather.demo_weather_north
        - entity: weather.demo_weather_north
          type: 0
        - entity: weather.demo_weather_north
          type: 1
        - entity: weather.demo_weather_north
          type: 2
        - entity: sensor.energy_usage

I guess you are using the old config way with one weather entity for the screensaver? Didn't really think about that one.

tetele commented 3 months ago

That is what i was using, yes.

TheGroundZero commented 3 months ago

Just a small remark.

If the state (and attributes) of weather.home is stored in the daily variable, you can pull all template data from said variable? Or skip the variable all together and use the source entity for the template?

# ...
sensor:
  - name: Weather Forecast Daily
    unique_id: weather_forecast_daily
    state: "{{ daily['weather.home'] }}"
    attributes:
      temperature: "{{ daily['weather.home'].temperature }}"
      temperature_unit: "{{ daily['weather.home'].temperature_unit }}"
      forecast: "{{ daily['weather.home'].forecast }}"

or

# ...
sensor:
  - name: Weather Forecast Daily
    unique_id: weather_forecast_daily
    state: "{{ states('weather.home') }}"
    attributes:
      temperature: "{{ state_attr('weather.home', 'temperature') }}"
      temperature_unit: "{{ state_attr('weather.home', 'temperature_unit') }}}"
      forecast: "{{ state_attr('weather.home', 'forecast') }}"

The code on this project's docs also mixes 2 entities (weather.home and weather.k3ll3r). https://docs.nspanel.pky.eu/stable/prepare_ha/#installing-lovelace-appdaemon-backend-application

Semantically it's also weird to use a variable named daily even though the trigger is hourly. There's an example code snipper on the HA docs that closely matches the template used here and it uses hourly as variable name: https://www.home-assistant.io/integrations/template/#trigger-based-handling-of-service-response-data

I also don't see a real reason to make this a trigger-based template but I might be overlooking something?

joBr99 commented 3 months ago

With the upcoming homeassistant version the weather entities are no longer providing the forecast attribute and the forecast has to be pulled though the weather.get_forecasts service. As appdaemon currently doesn't support calling services with a response, we still need an entity containing this data - this entity is generated with the trigger template.

For the current temperature it doesn't really matter if you are using the variable or the current state.

In homeassistant's example they are using the data type hourly for the forecast. In my example the data type daily is used. (would be possible to rename the variable to forecast or something like that to make it a bit more universal) However the daily forecast entity is updated hourly, as it's possible that the forecast is changing during the day ;)

denislooby commented 3 months ago

Working good for me using this now. Took a while, I missed the bit about the upgrade to AppDaemon 15 https://github.com/joBr99/nspanel-lovelace-ui/issues/1029 So my update in HACS was having no effect. If you are seeing ! instead of weather symbols follow that upgrade to appdaemon 15 how to.

ppaciekq commented 3 months ago

I used the workaround described here: https://docs.nspanel.pky.eu/stable/prepare_ha/#installing-lovelace-appdaemon-backend-application

but I still have a problem.

The screen looks like this: image

and this is what the configuration.yaml and apps.yaml files look like:

image image

image

what am I doing wrong? Any ideas?

joBr99 commented 3 months ago

adjust the weather.k3ll3r in your template to your weather entity weather.home

ppaciekq commented 3 months ago

yes, I noticed it and after changing it it actually works - thanks! However, only today's weather is visible. Is it possible to somehow add a view of the next few days?

joBr99 commented 3 months ago

319624684-b7026317-b8cf-4d88-b96e-fae92ed64fbf~2

ppaciekq commented 3 months ago

I changed it here. So I understand that after 1 hour the trigger should change it?

joBr99 commented 3 months ago

Check the data of the sensor.weather forecast daily entity - forecast data must be populated there

Maybe you can trigger the template by restarting HA, not sure.

ppaciekq commented 3 months ago

image

data in forecast home are visible correctly (daily and hourly): image

joBr99 commented 3 months ago

please check on this page:

image

tetele commented 3 months ago

Maybe you can trigger the template by restarting HA, not sure.

It won't. Only triggers can update trigger-based sensors.

What I did was this

template:
  - trigger:
      - platform: time_pattern
        hours: /1
      - platform: event
        event_type: event_template_reloaded
# everything else

then go to the Developer tools and reload Template entities.

If that doesn't work, try this

template:
  - trigger:
      - platform: time_pattern
        hours: /1
      - platform: event
        event_type: manual_event_template_reloaded

and add this automation:

alias: Re-emit event_template_reloaded event
description: >-
  In order to update trigger-based `template` entities, to prevent a race
  condition, I need to re-emit the `event_template_reloaded` event.
trigger:
  - platform: event
    event_type: event_template_reloaded
    event_data: {}
condition: []
action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - event: manual_event_template_reloaded
    event_data: {}
mode: single

then reload the Template entities

ppaciekq commented 3 months ago

image of course HA was restarted

ppaciekq commented 2 months ago

Maybe you can trigger the template by restarting HA, not sure.

It won't. Only triggers can update trigger-based sensors.

What I did was this

template:
  - trigger:
      - platform: time_pattern
        hours: /1
      - platform: event
        event_type: event_template_reloaded
# everything else

then go to the Developer tools and reload Template entities.

If that doesn't work, try this

template:
  - trigger:
      - platform: time_pattern
        hours: /1
      - platform: event
        event_type: manual_event_template_reloaded

and add this automation:

alias: Re-emit event_template_reloaded event
description: >-
  In order to update trigger-based `template` entities, to prevent a race
  condition, I need to re-emit the `event_template_reloaded` event.
trigger:
  - platform: event
    event_type: event_template_reloaded
    event_data: {}
condition: []
action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - event: manual_event_template_reloaded
    event_data: {}
mode: single

then reload the Template entities

I made the changes you wrote about and now the configuration looks like this:

image

forecast seems to be working properly now:

image

but there is still no information about the next few days and the icons are also missing:

image

tetele commented 2 months ago

Quoting joBr99's comment:

This also requires two slight changes in the backed to force the entity type of this newly created sensor to weather. So it also requires an update of the backend to current dev version. (or you just do those two changes manually) https://github.com/joBr99/nspanel-lovelace-ui/commit/d94d937d776c9ca9dd5cf083c54fc4c51d02af5f https://github.com/joBr99/nspanel-lovelace-ui/commit/e5c1f0588a3dfc226f129c822bfa83571fd2d240

Have you done that too?

ppaciekq commented 2 months ago

Quoting joBr99's comment:

This also requires two slight changes in the backed to force the entity type of this newly created sensor to weather. So it also requires an update of the backend to current dev version. (or you just do those two changes manually) d94d937 e5c1f05

Have you done that too?

Actually - I missed it. I have already added it and the icons are visible. Thanks for the help!

azsoccerpop commented 2 months ago

Apologies for jumping on but I am stuck on the weather fix. I changed my weather integration to Pirate Weather which correctly response to the service.get_forecasts and populates sensor.weather_forecast_daily with all the correct information as verified in the developer tools States. AppDaemon is at latest version NSPanel Lovelace UI is v4.4.0. AppDaemon Log shows this: 2024-04-05 14:43:59.185926 INFO nspanel-1: Sending MQTT Message: weatherUpdate~���~31728~PirateWeather~67��F~���~17299~Weather Forecast Daily~clou ~���~17299~Weather Forecast Daily~clou ~���~17299~Weather Forecast Daily~clou ~~~���~17299~Weather Forecast Daily~clou apps.yaml `screensaver:
entities:

joBr99 commented 2 months ago

are you sure that you are on v4.4.0? did you restart appdaemon? is appdaemon using the stuff downloaded from hacs? (only the case if you have app_dir in your appdaemon.yaml) see #1029

azsoccerpop commented 2 months ago

Thank you so much! I had not configured app_dir: /homeassistant/appdaemon/apps/ in the appdaemon.yaml. All is well.

rockyhopper commented 2 months ago

Thank you so much! I had not configured app_dir: /homeassistant/appdaemon/apps/ in the appdaemon.yaml. All is well.

Same issue for me. Solved for me too. Thanks a lot.

filipsworks commented 2 months ago

came up with a different workaround to keep home assistant providing the forecast as an entity

https://docs.nspanel.pky.eu/stable/prepare_ha/#workaround-for-homeassistant-202404

This also requires two slight changes in the backed to force the entity type of this newly created sensor to weather. So it also requires an update of the backend to current dev version.

(or you just do those two changes manually) d94d937 e5c1f05

It would be great to add homeassistant start trigger to that template as at least for me restarting the HA does not update the template itself:

template:
  - trigger:
      - platform: time_pattern
        hours: /1
      - platform: homeassistant
        event: start
joBr99 commented 2 months ago

thanks, good idea added to the documentation

soyxan commented 1 month ago

I have implemented the workaround configuration in my HA but this is the result I get in my nspanel:

20240515_091326

As you can see the current and forecast temperatures are fine, but the weather conditions icons and the weekdays names are missing. These were working fine before the AppDaemon issue.

This is my configuration.yaml:

template:
  - trigger:
      - platform: time_pattern
        hours: /1
      - platform: homeassistant
        event: start
    action:
      - service: weather.get_forecasts
        data:
          type: daily
        target:
          entity_id: weather.aemet # change to your weather entity
        response_variable: daily
    sensor:
      - name: Weather Forecast Daily
        unique_id: weather_forecast_daily
        state: "{{ states('weather.aemet') }}" # # change to your weather entity in this line
        attributes:
          temperature: "{{ state_attr('weather.aemet', 'temperature') }}" # change to your weather entity
          temperature_unit: "{{ state_attr('weather.aemet', 'temperature_unit') }}" # change to your weather entity
          forecast: "{{ daily['weather.aemet'].forecast }}" # change to your weather entity

And this is my screensaver configuration in apps.yaml:

nspanel_salon:
  module: nspanel-lovelace-ui
  class: NsPanelLovelaceUIManager
  config:
    screensaver:
      entities:
        - entity: sensor.weather_forecast_daily
          value: '{{states("sensor.ewelink_th01_a6451925_temperature")}} º'
        - entity: sensor.weather_forecast_daily
          type: 0
          value: "{{state_attr('sensor.weather_forecast_daily', 'forecast')[0].temperature|round(0)}}º/{{state_attr('sensor.weather_forecast_daily', 'forecast')[0].templow|round(0)}}º"
        - entity: sensor.weather_forecast_daily
          type: 1
          value: "{{state_attr('sensor.weather_forecast_daily', 'forecast')[1].temperature|round(0)}}º/{{state_attr('sensor.weather_forecast_daily', 'forecast')[1].templow|round(0)}}º"
        - entity: sensor.weather_forecast_daily
          type: 2
          value: "{{state_attr('sensor.weather_forecast_daily', 'forecast')[2].temperature|round(0)}}º/{{state_attr('sensor.weather_forecast_daily', 'forecast')[2].templow|round(0)}}º"
        - entity: delete
        - entity: sensor.nspanel_salon_thermostat_temperature
          value: '{{states("sensor.nspanel_salon_thermostat_temperature")}} º'
          icon: mdi:home-thermometer-outline

Am I missing anything? Thanks!

joBr99 commented 1 month ago

You need to upgrade the backend to the latest version.

Note that you might run into an issue if you didn't follow all of the steps during migration from appdaemon 14 to 15. Appdaemon is only using files from HACS if you have app_dir configured in the appdaemon.yaml. Please see: https://github.com/joBr99/nspanel-lovelace-ui/issues/1029

soyxan commented 1 month ago

I do not use the Appdaemon addon, I use it in docker, so my AppDaemon version is v4.4.2 (latest).

What do you mean by upgrade the backend? Are you referring to NSPanel Lovelace UI Backend in HACS? I am already using v4.4.0 and I do not see any pending update in HACS...

soyxan commented 1 month ago

Now is working. While I was writing my previous reply I realized that rebooting HA did not reboot Appdaemon (both are independent docker instances). After rebooting Appdaemon docker everything is working as expected. Thanks and sorry for my confusion!