NSPanel and Home Assistant widgets, need help!?

I have the following entities that get their states from an NS panel running tasmota

sensor:
  - platform: mqtt
    name: "Hallway Temp"
    unique_id: hallway_temp
    device_class: temperature
    unit_of_measurement: 'ºC'
    state_topic: "AcHallways/Temp/Stat"

  - platform: mqtt
    state_topic: 'tele/LoungeRoomSwitch/RESULT'
    unique_id: 'NSPPanel_ID'
    name: 'NS Panel ID'
    value_template: '{{ value_json.NSPanel.id }}'

  - platform: mqtt
    state_topic: 'tele/LoungeRoomSwitch/RESULT'
    unique_id: 'NSPPanel_Switch'
    name: 'NS Panel Switch'
    value_template: '{{ value_json.NSPanel.params.switch }}'  

  - platform: mqtt
    state_topic: 'tele/LoungeRoomSwitch/RESULT'
    unique_id: 'NSPPanel_Ltype'
    name: 'NS Panel Light Type'
    value_template: '{{ value_json.NSPanel.params.ltype }}' 
    
  - platform: mqtt
    state_topic: 'tele/LoungeRoomSwitch/RESULT'
    unique_id: 'NSPPanel_BR'
    name: 'NS Panel Brightness'
    value_template: '{{ value_json.NSPanel.params.white.br }}'  
    
  - platform: mqtt
    state_topic: 'tele/LoungeRoomSwitch/RESULT'
    unique_id: 'NSPPanel_CT'
    name: 'NS Panel Colour Temp'
    value_template: '{{ value_json.NSPanel.params.white.ct }}'  
    
  - platform: mqtt
    state_topic: 'tele/LoungeRoomSwitch/RESULT'
    unique_id: 'NSPPanel_Red'
    name: 'NS Panel Red'
    value_template: '{{ value_json.NSPanel.params.color.r }}'  
    
  - platform: mqtt
    state_topic: 'tele/LoungeRoomSwitch/RESULT'
    unique_id: 'NSPPanel_Green'
    name: 'NS Panel Green'
    value_template: '{{ value_json.NSPanel.params.color.g }}'  
    
  - platform: mqtt
    state_topic: 'tele/LoungeRoomSwitch/RESULT'
    unique_id: 'NSPPanel_Blue'
    name: 'NS Panel Blue'
    value_template: '{{ value_json.NSPanel.params.color.b }}'      
    
  - platform: mqtt
    state_topic: 'tele/LoungeRoomSwitch/RESULT'
    unique_id: 'NSPPanel_CBR'
    name: 'NS Panel Colour Brightness'
    value_template: '{{ value_json.NSPanel.params.color.br }}' 

the json state looks like this, it varies depending on what is pressed on the screen

{"NSPanel":{"id":"2","params":{"ltype":"color","color":{"r":0,"g":0,"b":0,"br":50}}}}
{"NSPanel":{"id":"2","params":{"ltype":"color","color":{"br":100}}}}
{"NSPanel":{"id":"2","params":{"ltype":"white","white":{"50":50,"ct":50}}}}
{"NSPanel":{"id":"2","params":{"switch":"on"}}}

So i have multiple entities to get this information.

I need to send an MQTT message back to the NS panel whenever i receive a tele message with any of these

I also want to use the data to switch certain lights on
ID = 1 will be my tall lamp
ID = 2 will be my small lamp
ID = 3 will be my LED strip.

Being a complete newbie to home assistant. what is the most efficient way of

  1. receive JSON message from tele/LoungeRoomSwitch/RESULT that looks like
{"NSPanel":{"id":"2","params":{"switch":"on"}}}
  1. Send JSON message back as command to cmnd/LoungeRoomSwitch/nspsend that looks like
{"relation":{"id":"2","online":true,"params":{"switch":"on"}}}

2a. Would be good to include the “online” status as true or false
3. use data from json to send commands to different items using the ID as the item selector.
4. If the item is sent commands from home assistant front end, i need to have a script to send a JSON command to the NS panel to update the screen showing the current state of the item.

Im working through this but wondering if there is someone who knows the best way to do this.

---------------------------------------------------UPDATE1 ------------------------------------------------------------

i now have this in my config.yaml

  - platform: mqtt
    state_topic: 'tele/LoungeRoomSwitch/RESULT'
    unique_id: 'NSPPanel_Lounge'
    name: 'NSPanel Lounge'
    value_template: "{{ value_json.NSPanel.params }}"
    json_attributes_topic: "tele/LoungeRoomSwitch/RESULT"
    json_attributes_template: "{{ value_json.NSPanel | tojson }}"

Which gives me attributes which is nice.
ID

2

Params

ID                     2
Params
                color:
                         b: 248
                         br: 50
                         g: 12
                         r: 0
ltype:           color

Next step is to have this returned back in a JSON command to cmnd/LoungeRoomSwitch/nspsend that looks like

{"relation":{"id":"2","online":true,"params":{xxxxxxxxx}}}

If anyone chimes in, help on this would be appreciated.

Update 2

I now have this automation which literally just sends the data back over MQTT to make sure the screen keeps the state that is pressed

alias: nspanel send data back
description: ''
trigger:
  - platform: state
    entity_id: sensor.ns_panel_raw_data
condition: []
action:
  - service: mqtt.publish
    data_template:
      topic: cmnd/LoungeRoomSwitch/nspsend
      payload: |

        {{'{{"relation":{}}}'.format(trigger.to_state.state)}}
mode: single

I also have this mqtt sensor in my config, which just saves the json state without NSPanel at the beginning.

  - platform: mqtt
    state_topic: 'tele/LoungeRoomSwitch/RESULT'
    unique_id: 'NSPPanel_RAW'
    name: 'NSPanel Raw Data'
    value_template: '{{ value_json.NSPanel }}'

Now to work out a way to send the JSON data to different light entities depending on the Device ID

Are you working on making the widgets working ? just for question … Does the panel have the possibility already to use it ? O don’t see that much l the last days and I’m planning to replace a bunch of my light switches with it

I am. Currently working on automatuons to use the widgets. I’ve got, colour, power and brightness working so far with some lights.

Do you know if climate works?

The climate page sends the status of the switch, and the required temperature set on the slider.
So you would need to use automatuons or scripts to turn on or off the air con depending on the difference between the set temp and the current temp

All the switch does is sent status of the screen presses. So colours. Brightness and switch status. Everything has to be automated using HA automatuons

If you turn on a home assistant switch, were you able to get the button icon on “nspanel” to light up as well?

Search for my posts in this thread

Hi @Chris_Hemmings

This might interest you : Mqtt messages with differen ID's, how to filter and avoid sensors without value - #6 by 123

I was trying to find a way to generate a sensor filtered on the specific ID.

- alias: "mqttsensor demultiplexer"
  mode: parallel
  trigger:
    - platform: mqtt
      topic: "tele/nspanel/RESULT"
  action:
    - service: mqtt.publish
      data:
        topic: "mqttsensor/{{ trigger.payload_json.NSPanel.id }}"
        payload: "{{ trigger.payload }}"
        retain: true
    - state_topic: mqttsensor/1
      unique_id: "nspanel_test"
      name: "NSPanel test"
      value_template: "{{ value_json.NSPanel.params.switch }}"