Code Monkey home page Code Monkey logo

Comments (12)

bugalaws avatar bugalaws commented on May 29, 2024 1

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!!

from node-red-contrib-tasmota.

DaveMDS avatar DaveMDS commented on May 29, 2024

Hi,
to use the single output mode you set in the configuration "1 Channel (or all merged)"

from node-red-contrib-tasmota.

bugalaws avatar bugalaws commented on May 29, 2024

Sorry for deleted messages i will describe better below...

I my tasmota i have this setup:

image

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:
image
This way work with all channels merged, like espected for this setup.

The second one i setup with three channels:
image
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:
image

or this way:
image

I got offline

image

Sorry i know it probably is a noob configure question, but if your can help me i'm so glad...

from node-red-contrib-tasmota.

bugalaws avatar bugalaws commented on May 29, 2024

To resume the doubt is how to setup 1 channel to got the click events of a button3 for exemple....

from node-red-contrib-tasmota.

bugalaws avatar bugalaws commented on May 29, 2024

0DCF7F76-AF86-4882-A661-12D460FD6500

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..

from node-red-contrib-tasmota.

bugalaws avatar bugalaws commented on May 29, 2024

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%...

from node-red-contrib-tasmota.

DaveMDS avatar DaveMDS commented on May 29, 2024

If you need only button 3 events you should setup as you have done in your second image:
144498567-81541819-8950-4906-8b7b-289939253b1c

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

from node-red-contrib-tasmota.

bugalaws avatar bugalaws commented on May 29, 2024

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....

from node-red-contrib-tasmota.

bugalaws avatar bugalaws commented on May 29, 2024

button.zip

here is my changed files

from node-red-contrib-tasmota.

DaveMDS avatar DaveMDS commented on May 29, 2024

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.

from node-red-contrib-tasmota.

bugalaws avatar bugalaws commented on May 29, 2024

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….

3FF5A23A-4AC3-4C07-B9B4-5C1FA3C352B8

I know this is a so much personal, but i think more users will like it.

By the way, sorry for any inconvenance…

from node-red-contrib-tasmota.

DaveMDS avatar DaveMDS commented on May 29, 2024

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"

from node-red-contrib-tasmota.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.