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

AttributeError: 'AttrDict' object has no attribute 'forecast' #1233

Closed Michael-Kaempf closed 2 weeks ago

Michael-Kaempf commented 2 weeks ago

PROBLEM DESCRIPTION

Icons for weather are not shown on screensaver anymore.

REQUESTED INFORMATION

apps.yaml:

nspanel-oben:
  module: nspanel-lovelace-ui
  class: NsPanelLovelaceUIManager
  config:
    panelRecvTopic: "tele/nspanel_C1B6E8/RESULT"
    panelSendTopic: "cmnd/nspanel_C1B6E8/CustomSend"
    model: "eu"
    sleepTimeout: 10
    sleepBrightness:
      - time: "sunrise - 0:30:00"
        value: 5
      - time: "sunset + 0:30:00"
        value: 1
    locale: "de_DE"
    screensaver:
      entity: weather.openweathermap

output of the log during your issue/bug occurs:

2024-06-15 11:20:30.845175 WARNING nspanel-oben: ------------------------------------------------------------
2024-06-15 11:20:30.846855 WARNING nspanel-oben: Unexpected error in worker for App nspanel-oben:
2024-06-15 11:20:30.847680 WARNING nspanel-oben: Worker Ags: {'id': 'cd3f2b6d87f948ba924b801385828371', 'name': 'nspanel-oben', 'objectid': '52fe3f5e871d49d6b2d828f78e260fb8', 'type': 'state', 'function': <bound method LuiController.state_change_callback of <luibackend.controller.LuiController object at 0x7f8bf8dbd0>>, 'attribute': 'all', 'entity': 'weather.openweathermap', 'new_state': {'entity_id': 'weather.openweathermap', 'state': 'cloudy', 'attributes': {'temperature': 15.9, 'apparent_temperature': 15.8, 'dew_point': 13.5, 'temperature_unit': '°C', 'humidity': 86, 'cloud_coverage': 100, 'pressure': 1007.0, 'pressure_unit': 'hPa', 'wind_bearing': 219, 'wind_gust_speed': 52.24, 'wind_speed': 20.74, 'wind_speed_unit': 'km/h', 'visibility_unit': 'km', 'precipitation_unit': 'mm', 'attribution': 'Data provided by OpenWeatherMap', 'friendly_name': 'OpenWeatherMap', 'supported_features': 3}, 'last_changed': '2024-06-15T09:10:30.758359+00:00', 'last_reported': '2024-06-15T09:20:30.793548+00:00', 'last_updated': '2024-06-15T09:20:30.793548+00:00', 'context': {'id': '01J0DK5HJ9RVHFB8Q8BFHYGBRJ', 'parent_id': None, 'user_id': None}}, 'old_state': {'entity_id': 'weather.openweathermap', 'state': 'cloudy', 'attributes': {'temperature': 15.5, 'apparent_temperature': 15.3, 'dew_point': 13.3, 'temperature_unit': '°C', 'humidity': 87, 'cloud_coverage': 100, 'pressure': 1007.0, 'pressure_unit': 'hPa', 'wind_bearing': 219, 'wind_gust_speed': 52.24, 'wind_speed': 20.74, 'wind_speed_unit': 'km/h', 'visibility_unit': 'km', 'precipitation_unit': 'mm', 'attribution': 'Data provided by OpenWeatherMap', 'friendly_name': 'OpenWeatherMap', 'supported_features': 3}, 'last_changed': '2024-06-15T09:10:30.758359+00:00', 'last_reported': '2024-06-15T09:10:30.758359+00:00', 'last_updated': '2024-06-15T09:10:30.758359+00:00', 'context': {'id': '01J0DJK7K6DWJDVK904XCZKPX5', 'parent_id': None, 'user_id': None}}, 'pin_app': True, 'pin_thread': 2, 'kwargs': {'attribute': 'all', '__thread_id': 'thread-2'}}
2024-06-15 11:20:30.848329 WARNING nspanel-oben: ------------------------------------------------------------
2024-06-15 11:20:30.852474 WARNING nspanel-oben: Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/appdaemon/threading.py", line 1045, in worker
    funcref(
  File "/config/apps/nspanel-lovelace-ui/luibackend/controller.py", line 174, in state_change_callback
    self._pages_gen.render_card(self._current_card, send_page_type=False)
  File "/config/apps/nspanel-lovelace-ui/luibackend/pages.py", line 821, in render_card
    self.update_screensaver_weather(theme)
  File "/config/apps/nspanel-lovelace-ui/luibackend/pages.py", line 153, in update_screensaver_weather
    item_str += self.generate_entities_item(item, "cardEntities", mask=["type", "entityId"])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/apps/nspanel-lovelace-ui/luibackend/pages.py", line 386, in generate_entities_item
    if type(item.stype) == int and len(entity.attributes.forecast) >= item.stype:
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'AttrDict' object has no attribute 'forecast'

TO REPRODUCE

  1. add hacs-addon to home assistant
  2. flash tasmota to ns-panel
  3. setup MQTT at broker & panel
  4. setup nspanel-lovelace-ui with screensaver as described here

EXPECTED BEHAVIOUR

Current weather and weather forecast should be shown.

SCREENSHOTS

image

ADDITIONAL CONTEXT

none

PANEL / FIRMWARE VERSION

Program Version | 13.0.0.1(nspanel) Build Date & Time | 2023-07-01T12:35:55 Core/SDK Version | 2_0_10/4.4.5.230614

EU Version

joBr99 commented 2 weeks ago

Please see #1204 and release notes of the latest version.