Closed bugalaws closed 2 years ago
Hi, to use the single output mode you set in the configuration "1 Channel (or all merged)"
Sorry for deleted messages i will describe better below...
I my tasmota i have this setup:
When I click in button 1 for exemple i got this at the tasmota console:
21:26:13.431 MQT: stat/tasmota_44D83C/RESULT = {"Button1":{"Action":"SINGLE"}}
When I click in button 2 for exemple i got this at the tasmota console:
21:27:16.369 MQT: stat/tasmota_44D83C/RESULT = {"Button2":{"Action":"SINGLE"}}
At the node i have three test setups, the first one is setup with a one channel or merge:
This way work with all channels merged, like espected for this setup.
The second one i setup with three channels: Works fine too, each out channel represent a button, and it works fine.
So I have the thirdy scenary.. where i need only one node and get only the button 3 (single, double and hold status) i'm not know how configure correctly because i got offline status when i try especify the topic/button3 for exemple:
if i try this way:
or this way:
I got offline
Sorry i know it probably is a noob configure question, but if your can help me i'm so glad...
To resume the doubt is how to setup 1 channel to got the click events of a button3 for exemple....
i made this exemple what i’m thinking
for example if in channels field set 1 and put “3” in channel number the node listen only button3 events….
Ofcourse i made only a change in the html file to exemplify what i’m thinking… i don’t know if have some way to do this..
I don't know if have the some way most easyer than this, but i make some changes em button.html, button.js and base_tasmota.js to implement this function, now fits in my necessity 100%...
If you need only button 3 events you should setup as you have done in your second image:
Just remove the two wires from output1 and output2 and leave only the wire connected to output3, your debug node will now receive only the events from button3
I don't know if you have interrest but i made some changes to i select what channel i want to listen when configured a single channel.. not is be amazing code but works .
in base_tasmota:
I add channelNumberId at const TASMOTA_DEFAULTS:
const TASMOTA_DEFAULTS = { // basic broker: '', // mandatory device: '', // mandatory name: '', outputs: 1, channelNumberId: '', uidisabler: false, // advanced fullTopic: '%prefix%/%topic%/', cmndPrefix: 'cmnd', statPrefix: 'stat', telePrefix: 'tele', qos: 1, retain: false }
in button.html i add a field below combobox of channels:
div class="form-row"> label for="node-input-outputs"> Channel Number input type="text" id="node-input-channelNumberId" placeholder="put 0(zero) to merge all channels"> /div>
and add channelNumberId: { value: 1}, in defaults of the script session:
defaults: {
// common basic
broker: { type: "tasmota-mqtt-broker", required: true },
device: { value: "", required: true },
name: { value: "" },
outputs: { value: 1 },
channelNumberId: { value: 1},
uidisabler: { value: false },
// common advanced
fullTopic: { value: "" },
cmndPrefix: { value: "" },
statPrefix: { value: "" },
telePrefix: { value: "" },
qos: { value: 1 },
retain: { value: false }
// node specific
},
in button.js i change this:
// update status icon and label
this.setNodeStatus('green', `${action} (${channel})`)
// build and send the new string message for topic 'buttonX'
const msg = { topic: 'button' + channel, payload: action }
if (this.config.outputs === 1 || this.config.outputs === '1') {
// everything to the same (single) output
this.send(msg)
} else {
// or send to the correct output
const msgList = Array(this.config.outputs).fill(null)
msgList[channel - 1] = msg
this.send(msgList)
}
to this:
// update status icon and label
if(parseInt(this.config.channelNumberId, 10) === 0 || parseInt(this.config.channelNumberId, 10) === channel){
this.setNodeStatus('green', `${action} (${channel})`)
}
// build and send the new string message for topic 'buttonX'
const msg = { topic: 'button' + channel, payload: action }
if (this.config.outputs === 1 || this.config.outputs === '1') {
// everything to the same (single) output
if(parseInt(this.config.channelNumberId, 10) === 0 || parseInt(this.config.channelNumberId, 10) === channel){
this.send(msg)
}
} else {
// or send to the correct output
const msgList = Array(this.config.outputs).fill(null)
msgList[channel - 1] = msg
this.send(msgList)
}
Works great maybe need some improvements but already works perctly to my scenario....
here is my changed files
before looking at the implementation details: I really don't understand why you need those changes, I already explained how to make what you need (without changing the code), and a new config option seems to me overkill and can confuse other users.
For example i have a tasmota with 16 buttons and will use one node in one flow where i will use the button16 only…. I don’t like to use one node with 16outputs and use only the 16th with 15 empty output….
I know this is a so much personal, but i think more users will like it.
By the way, sorry for any inconvenance…
Ah, 16 buttons, you did non say that before, your use case start to make sense now :-)
Btw, still think the new option is a bit overkill, and then we should also implement a more complex selection, fe: someone may want to just use button 4 and 12... that start to become more complex.
In this situation I suggest to use the Button node configured as "1 Channel (or all merged)" and then attach a standard nodered "switch" node, that you can configure with a filter like: msg.topic == "button16"
Thanks a lot Dave, i think i'll mantain my mod for now, btw will test like you explained... And congratulations your node is amazing!!
Hi Guys,
I'm using the node-red-contrib-tasmota, works great, but I can't configure a single output in a button node with a topic to distinguish the channel, ever i put the topic i get "offline" status....
Someone can help me explain how can i configure a single output with a distinguished channel by topic ?
In documentation say: "The node can be configured to send all press actions to a single output (in this case the topic is used to distinguish channels)"