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
- receive JSON message from tele/LoungeRoomSwitch/RESULT that looks like
{"NSPanel":{"id":"2","params":{"switch":"on"}}}
- 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.