Sonoff NSPanel by ITead - Smart Scene Wall Switch based on ESP32 and custom Nextion Touch Screen Panel Display (non-Pro variant)

Typically after posting my question a couple of hours later I found an alternative way to do it!

In Home Assistant I created a helper input_number.test_slider. Then created an automation that is triggered when the input_number.test_slider is moved which sets the NS Panel Screen Brightness slider to the same value

alias: Test Slider NS Panel Brightness Change
description: Test Slider Changes NS Panel Screen Brightness
trigger:
  - platform: state
    entity_id:
      - input_number.test_slider
    from: null
condition: []
action:
  - service: number.set_value
    target:
      entity_id: number.nspanel_brightness
    data:
      value: |
        {{ states('input_number.test_slider')|int(0) }}
mode: singletype or paste code here

I created a second automation that is triggered by the NS Panel lightslider being moved which sets the input_number.test_slider to the same value

alias: NS Panel Brightness Change
description: NS Panel Screen Brightness Changes Test Slider
trigger:
  - platform: state
    entity_id:
      - sensor.nspanel_lightslider
    from: null
condition: []
action:
  - service: input_number.set_value
    target:
      entity_id: input_number.test_slider
    data:
      value: |
        {{ states('sensor.nspanel_lightslider')|int(0) }}
mode: singletype or paste code here

I tried to use number.nspanel.brightness as the trigger entity_id and for the value in the second automation but it didn’t work. So I had to create a new sensor in the Esphome code

sensor:
  # Gets the value of the Screen Brightness into HA
  # Uses On Release code in the Nextion Screen Brightness slider for it to work.
  - platform: nextion
    id: lightslider
    name: lightslider
    variable_name: lightslidertype or paste code here

In the Nextion Editor add this code to the Touch Release Event for the Screen Brightness slider to pass the brightness value to Home Assistant via the lightslider sensor

printh 91
prints "lightslider",0
printh 00
prints n0.val,0
printh FF FF FF

Moving either slider now changes the screen brightness and the other sliders value and position so they stay in sync.

The only remaining issue is that the lightslider sensor shows as “Unknown” in Home Assistant until the Screen Brightness slider is moved. Trying to check for “Unknown” using isnan doesn’t work and I haven’t been able to find a way that does work.

sensor:
  # Gets the value of the Screen Brightness into HA
  # Uses On Release code in the Nextion Screen Brightness slider for it to work.
  - platform: nextion
    id: lightslider
    name: lightslider
    variable_name: lightslider
    filters:
      - lambda: !lambda |-
          if (isnan(x)) return 30;
          return x;

Hopefully other people will find this useful.

Anyone here ever succeeded in using PSRAM from NSPanel?

Been using GitHub - joBr99/nspanel-lovelace-ui: Custom Firmware for NsPanel with the design of HomeAssistant's lovelace UI in mind, works with Tasmota. for quite a long time succesfully. Now the panel is not responding to touch much at all.
Is there a way to boot the system? (other than removing house fuses…)

Have you tried the reset button in the bottom of the panel?

image

Thanks! Totally forgot that there’s a reset button. Pressing that didn’t help, just resulted in “Waiting for content” screen.
The Tasmota gui is working and there’s a reset option, also: same thing.

Somehow HA has lost the device totally.

EDIT: Updated HACS, AppDaemon, restarted HA… at least. Now NSPanel entities are seen by the HA again. Just the panel GUI is still missing.
Now it seems that the AppDaemon stops working.

EDIT2: AppDaemon secrets.yaml location needed an update, this solved it AppDaemon won't start - complains about secrets.yaml - #21 by p-x

2 Likes

I was thinking of something like this so really glad to hear you’ve got it working. Could you give more detail of what you did, I’d really like to do the same. E.g. some photos of the implementation, which sensor etc? It would be much appreciated.

Does anyone know if its possible to enable a “button released” command?

I am using @jobraun Lovelace UI with Tasmota, my buttons are decoupled from the relays and all working fine but id like to use a long press to Dim & Brighten some lights - without the button released command i just end up in a continuous loop, Any ideas?

2 Likes

Hi @jobraun

Thanks for giving my home so much joy with your NSpanel code !

I’m having an issue with the latest update 2024.04. I’ve followed creating the scripts as suggested on

However, I get this on my screen for the forecast dates

Here’s my scripts:

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}}"

and here is the other bit

  entities:
    - entity: weather.home
    - entity: sensor.weather_forecast_daily
      type: 0
    - entity: sensor.weather_forecast_daily
      type: 1
    - entity: sensor.weather_forecast_daily
      type: 2
    - entity: sensor.weather_forecast_daily
      type: 3
    - entity: sensor.ingham_imported_energy_cost
      name: $ Today
      icon: mdi:solar-power-variant

Any guidance on what I may need to change ?

All the best

Jason

Hi Jason,

Can I ask if your in Australia and using the BOM integration. As I have the same issue as yourself.

Hi Claire, yes in Oz, and no - just using the standard met.no forecast sensor that is installed by default by HASS.

I’m having the same issue. The main weather shows fine but none of the forecast. Hope that API gets updated soon.

I have this resolved now, the idea - smile slowly - first ensure your sensor is working. Note I changed the template to update each minute as seen below, will return this to hour later. So I can see changes, I commented out # forecast, and set the state, temperature, temperature_unit to a string.

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

When I could see the Entity in Dev Tools >> States as ‘sensor.weather_forecast_daily’ I then enabled states and Reloaded All YAML, when this showed correctly I enabled temperature and so on.

If you go to his Github ([BUG] HA 2024.4 - cannot display forecast properly · Issue #1209 · joBr99/nspanel-lovelace-ui · GitHub) you will see what the sensor should look like.

Then add the sensor to the panel and the world should be beautiful.

key: ssKey
statusIcon1:
  entity: switch.study_nsp_switch1
  altFont: True
  icon:
    "on": mdi:menu-up-outline
    "off": "text:"
statusIcon2:
  entity: switch.study_nsp_switch2
  altFont: True
  icon:
    "on": mdi:menu-up-outline
    "off": "text:"
entities:
  - entity: weather.bom
  - entity: sensor.weather_forecast_daily
    type: 0
  - entity: sensor.weather_forecast_daily
    type: 1
  - entity: sensor.weather_forecast_daily
    type: 2
  - entity: sensor.weather_forecast_daily
    type: 3
  - entity: sensor.study_nsp_temperature
    icon: mdi:home-thermometer-outline
alternativeLayout: false
defaultCard: navigate.studyKey
theme: !include /homeassistant/appdaemon/apps/nsp_theme.yaml
1 Like

OK - got it working on my end … and totally my fault …

I forgot to do the required directory change and update of Appdaemon stuff …

Once I did the below … all returned to normal

follow instructions in here

Thanks for the confidence to keep troubleshooting. My issue was also my fault. I already had a template entry in my config file and had double entries. Somehow I missed the error in studio code the first time around. DOH.

Hi,

there is now available 12VDC backplate for NSPanel: Smartavan 12VDC backplate for Sonoff NSPanel

2 Likes

Hello,

anyone here can help me out please ?

when adding this line: app_dir: /homeassistant/appdaemon/apps
to the appdaemon.yaml my nspanel stops working.
yes the nspanel files are in this folder but it doesn’t work.
Getting all kind of weird appdaemon errors like:

2024-04-21 18:52:15.802634 WARNING nspanel-1: Unexpected error running initialize() for nspanel-1
2024-04-21 18:52:15.803151 WARNING nspanel-1: ------------------------------------------------------------
2024-04-21 18:52:15.808501 WARNING nspanel-1: Traceback (most recent call last):
File “/usr/lib/python3.11/site-packages/appdaemon/app_management.py”, line 162, in initialize_app
await utils.run_in_executor(self, init)
File “/usr/lib/python3.11/site-packages/appdaemon/utils.py”, line 304, in run_in_executor
response = future.result()
^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/concurrent/futures/thread.py”, line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/homeassistant/appdaemon/apps/nspanel-lovelace-ui/nspanel-lovelace-ui.py”, line 18, in initialize
apis.ha_api = self.get_plugin_api(“HASS”)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/site-packages/appdaemon/utils.py”, line 231, in inner_sync_wrapper
f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/site-packages/appdaemon/utils.py”, line 313, in run_coroutine_threadsafe
result = future.result(self.AD.internal_function_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/concurrent/futures/_base.py”, line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/concurrent/futures/_base.py”, line 401, in __get_result
raise self._exception
File “/usr/lib/python3.11/site-packages/appdaemon/adbase.py”, line 115, in get_plugin_api
return await self.AD.plugins.get_plugin_api(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/site-packages/appdaemon/plugin_management.py”, line 404, in get_plugin_api
mod = import(module_name, globals(), locals(), [module_name], 0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/homeassistant/appdaemon/apps/omnikdatalogger/omnik/plugin_localproxy/hassapi.py”, line 6, in
class HASSAPI(LocalProxyPlugin):
File “/homeassistant/appdaemon/apps/omnikdatalogger/omnik/plugin_localproxy/init.py”, line 7, in init
cls.register(cls) # Called when a plugin class is imported
^^^^^^^^^^^^^^^^^

Some guys at NSPanel HA Blueprint figured it out, works with any esphome config :slight_smile:

16MB PSram can now be pretty useful for BLE and stuff.

esp32:
  framework:
    sdkconfig_options:
      CONFIG_D0WD_PSRAM_CLK_IO: "5"
      CONFIG_D0WD_PSRAM_CS_IO: "18"

psram:

Also still preferring and using the stock UI, now it has a black wallpaper option as well to use.

1 Like

A 1-color background would be quite easy to implement. And even if we want 3 or 4 different colors. :wink:

By the way, I’m one of those guys who set the PSRAM… Finally. :wink:

1 Like