nspanel-lovelace-ui icon indicating copy to clipboard operation
nspanel-lovelace-ui copied to clipboard

[Feature Request] sensor sun

Open jrspowers opened this issue 3 years ago • 4 comments

hello is it possible to add the sun.sun sensor to the sensor would you like to use it ?

2022-06-16 15:45:50.590679 INFO nspanel: Received Message from Screen: event,buttonPress2,sun.sun,button
2022-06-16 15:45:50.594930 INFO nspanel: Button Press Event; entity_id: sun.sun; button_type: button; value: None 
2022-06-16 15:45:50.602663 WARNING nspanel: ------------------------------------------------------------
2022-06-16 15:45:50.603783 WARNING nspanel: Unexpected error in worker for App nspanel:
2022-06-16 15:45:50.604968 WARNING nspanel: Worker Ags: {'id': '8fe0baf22154499899745a6f107167f1', 'name': 'nspanel', 'objectid': '2d97d3c927074b7999222461fb7f10b6', 'type': 'event', 'event': 'MQTT_MESSAGE', 'function': <bound method LuiMqttListener.mqtt_event_callback of <luibackend.mqttListener.LuiMqttListener object at 0x7ff5e0534dc0>>, 'data': {'topic': 'tele/tasmota_your_mqtt_topic/RESULT', 'wildcard': None, 'payload': '{"CustomRecv":"event,buttonPress2,sun.sun,button"}'}, 'pin_app': True, 'pin_thread': 0, 'kwargs': {'topic': 'tele/tasmota_your_mqtt_topic/RESULT', '__thread_id': 'thread-0'}}
2022-06-16 15:45:50.605999 WARNING nspanel: ------------------------------------------------------------
2022-06-16 15:45:50.607589 WARNING nspanel: Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/appdaemon/threading.py", line 950, in worker
    funcref(args["event"], data, self.AD.events.sanitize_event_kwargs(app, args["kwargs"]))
  File "/config/appdaemon/apps/nspanel-lovelace-ui/luibackend/mqttListener.py", line 58, in mqtt_event_callback
    self._controller.button_press(entity_id, btype, value)
  File "/config/appdaemon/apps/nspanel-lovelace-ui/luibackend/controller.py", line 263, in button_press
    self._ha_api.get_entity(entity_id).call_service("press")
  File "/usr/lib/python3.10/site-packages/appdaemon/utils.py", line 226, in inner_sync_wrapper
    f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
  File "/usr/lib/python3.10/site-packages/appdaemon/utils.py", line 346, in run_coroutine_threadsafe
    result = future.result(self.AD.internal_function_timeout)
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 446, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 391, in __get_result
    raise self._exception
  File "/usr/lib/python3.10/site-packages/appdaemon/entity.py", line 358, in call_service
    return await self.AD.services.call_service(namespace, domain, service, kwargs)
  File "/usr/lib/python3.10/site-packages/appdaemon/services.py", line 155, in call_service
    raise DomainException("Unknown domain (%s/%s) in call_service from %s", namespace, domain, name)
appdaemon.exceptions.DomainException: ('Unknown domain (%s/%s) in call_service from %s', 'default', 'sun', 'nspanel')
2022-06-16 15:45:50.608385 WARNING nspanel: ------------------------------------------------------------

Panel / Firmware Version Please add the Panel/Firmware Version you are using (EU)

jrspowers avatar Jun 16 '22 13:06 jrspowers

can you add this?

jrspowers avatar Aug 01 '22 00:08 jrspowers

@joBr99, it could be implemented as the following, in pages.py, before L260:

if entityType == "sun":
    icon_color = rgb_dec565([253, 216, 53])
    if entity.state == "above_horizon":
      icon_id = get_icon_id("weather-sunset-up")
    if entity.state == "below_horizon":
      icon_id = get_icon_id("weather-sunset-down")
    text = get_translation(self._locale, f"backend.component.sun.state._.{entity.state}")
    return f"~text~{entityId}~{icon_id}~{icon_color}~{name}~{text}"

I've just noticed by adding the sun sensor, that long text strings such as "Above Horizon" in french as an example, in the cardEntities, are cut when they are too long. Maybe a line break could be added ?

WhistleMaster avatar Aug 13 '22 17:08 WhistleMaster

Will have a look later, Nextion isn't able to do it automatically, but you can send a string with line breaks, but in cardEntities the text field is probably not tall enough, have to check.

joBr99 avatar Aug 13 '22 17:08 joBr99

Sure ! I've made a quick PR if it's ok for you #400.

WhistleMaster avatar Aug 13 '22 18:08 WhistleMaster