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

@jobraun is the bloody best !

Works perfectly - thank you so much !!

2 Likes

Y’all going to need this today after the Appdaemon update …

1 Like

Hi All,
Before all the recent changes I would use a include statement that looked like
!include /config/appdaemon/apps/nsp-masterss.yaml.
This for obvious reasons no longer works.

Unfortunately I have tried a few combo’s (randomly) i.e.
!include /addon_configs/a0d7b954_appdaemon/apps/nsp-masterss.yaml
Can somebody point me in the correct direction to using includes correctly in the new world.

Thanks Heaps

1 Like

edit: i seem to be blind and/or dumb, since Blakadder had already updated their document…

Found it some time later :sweat_smile: had to uart the Nextion, but here it is for those still rocking the stock:

  - platform: template
    name: Wallpaper
    id: ${device_name}_wallpaper
    icon: mdi:cat # mdi:wallpaper
    entity_category: config
    optimistic: true
    restore_mode: RESTORE_DEFAULT_OFF
    turn_on_action: # „ºU™á.."HMI_wallpaper":1m2U™Ö'. 0x87 135 {"HMI_wallpaper":1}
      lambda: |-
        id(ns_panel).send_json_command(0x87, "{\"HMI_wallpaper\":1}");
    turn_off_action:
      lambda: |-
        id(ns_panel).send_json_command(0x87, "{\"HMI_wallpaper\":0}");

Can microphone be used by esphome firmware? I have searched a lot but have not found a single mention of GPIO where microphone is connected, other than it has microphone (in marketing materials)

Sounds like you are confusing the original “Sonoff NSPanel” which this thread is about with the “Sonoff NSPanel Pro”(?), as the former that is based on an Esspressif ESP32 does not have a built-in microphone but the latter that is based on Android OS does, (note that they are not based on the same platform components at all, as you might understand).

Or do you mean you soldering your own microphone to the original “Sonoff NSPanel” (which this thread is about)?

Anyway, the ESPHome does support Microphone Components if the hardware is already connected, see → Microphone Components — ESPHome

For a ESP32 development kit hardware with built-in microphone (and speaker) check out Espressif ESP32-S3-BOX-3 and the M5Stack Atom Echo.
ESP Home and ESP32 S3 Box? or for better hardware the Onju Voice (Google Nest Mini speaker replacement PCB with ESP32-S3):

thanks. According to the description, NSpanel (not PRO version) does have microphone:

https://itead.cc/product/sonoff-nspanel-smart-scene-wall-switch/

【Multiple Ways to Control】You can use the dual-channel switches, touchscreen, and eWeLink App to control SONOFF NSPanel; Besides, SONOFF NSPanel supports Alexa , Alice , Google Assistant , and even Siri Shortcuts , you can control your home appliances with simple voice control.

ah, I see now how they mean it. So it does not have microphone indeed. Sad.

The original original “Sonoff NSPanel” does not have a built-in microphone, and its description only mentions that it can be integrated (over a WiFi network) and controlled by third-party smart home ecosystems like Alexa (e.i. Amazon Echo smart speakers/displays) and Google Assistant (e.i. Google Home/Nest smart speakers/displays).

Hi Blackadder. Sorry I am very inexperiences, but do you have a photo or info on what pins to connect to 5V for the spaniel pro please?

This is used in the Esphome code for a Sonoff NS Panel, using Esphome 2023-11-6.

number:
  # Screen brightness
  - platform: template
    name: Brightness
    id: brightness
    entity_category: config
    unit_of_measurement: '%'
    min_value: 0
    max_value: 100
    step: 1
    initial_value: 30
    set_action:
      then:
        - lambda: 'id(disp1).set_backlight_brightness(x/100);'
        - lambda: 'id(disp1).send_command_printf("Home.brightness.val=%i", int(x));'
        - lambda: 'id(disp1).send_command_printf("Settings.n0.val=%i", int(x));'
        - lambda: 'id(disp1).send_command_printf("Settings.bright.val=%i", int(x));'

It creates a “Brightness” slider control in Home Assistant that has an initial value of 30. When it’s moved, the control shows the value it is moved to and it sends that value to the NS Panel using the set_action: lines. This is all working correctly.

Using the touch screen on the NS Panel you can also set the screen brightness using a “Screen Brightness” slider control. I have managed to get the “Brightness” slider in Home Assistant to move the NS Panel “Screen Brightness” slider position and it’s value to match the Home Assistant “Brightness” position and value so they stay in sync.

What I have been unable to do after nearly 3 days of searching, reading and trying different methods is to make the “Brightness” control in Home Assistant change position and value to match the NS Panel “Screen Brightness” slider when that is moved. I don’t think the problem I’m having is just because it’s a Sonoff NS Panel I’m using it with. I think I’m just not using the correct method to do it, but I could be wrong.

Has anyone any suggestions on what I’m doing wrong and how to achieve this?

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.