publish/subscribe help

68 views
Skip to first unread message

adcciuca

unread,
May 8, 2020, 1:30:40 AM5/8/20
to souliss
Hi All,

i am trying to develop the code for controlling some lights,and  cant get my head around it.   every light need to be  triggered from its own peer ( via publish) and souliss app. Also when the light is on or off a feedback signal need to be published so the light in the button changes color respectively. 

managed to get it running from the button but not from the app.  Any suggestions? 


06.05.ino
peers.h
slots.h
topics.h

Di Maio, Dario

unread,
May 8, 2020, 2:08:47 AM5/8/20
to sou...@googlegroups.com
Hi,

I assume that you have buttons and lights on different nodes, is it?

Dario.

--
You received this message because you are subscribed to the Google Groups "souliss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to souliss+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/souliss/b78ed928-b89e-4884-a936-c676ee179ef9%40googlegroups.com.

adcciuca

unread,
May 8, 2020, 2:14:42 AM5/8/20
to souliss
yes Dario,

all on different nodes


vineri, 8 mai 2020, 09:08:47 UTC+3, Dario Di Maio a scris:
Hi,

I assume that you have buttons and lights on different nodes, is it?

Dario.

On Fri, 8 May 2020, 07:30 adcciuca <adcc...@gmail.com wrote:
Hi All,

i am trying to develop the code for controlling some lights,and  cant get my head around it.   every light need to be  triggered from its own peer ( via publish) and souliss app. Also when the light is on or off a feedback signal need to be published so the light in the button changes color respectively. 

managed to get it running from the button but not from the app.  Any suggestions? 


--
You received this message because you are subscribed to the Google Groups "souliss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sou...@googlegroups.com.

Di Maio, Dario

unread,
May 8, 2020, 2:24:15 AM5/8/20
to sou...@googlegroups.com
The information that you have provided are not enough to help, I just see one side of the sketch.

All buttons are connected to a single node and lights are distributed accross several nodes? If so, set the nide with buttons as Gateway with LastIn and you will all data from lights available in the Gateway node.

You will anyhow be able to have an another Gateway to be used with SoulissApp or opemHab if you need.

Dario.

To unsubscribe from this group and stop receiving emails from it, send an email to souliss+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/souliss/6201c6b0-3988-471e-897f-10d05f4b32fd%40googlegroups.com.

adcciuca

unread,
May 8, 2020, 5:16:12 AM5/8/20
to souliss
hi,  all outputs to  the lights are handled in 2 peers "peer_etaj_lumini_1"and "peer_etaj_lumini_2"  and  each button publish   Topic_slot_toggle  message . Buttons are grouped in  Gewiss type modular fixtures . One modular fixture gathers up to 7 inputs and publish the Toggle message according to the buton designation. Butons are  capacitive touch (hardware) and have the back light that have to change according to the light condition (off -red-on green) 

The gateway only connects the peers and handles comunications. 

i hope it makes sense.

peer_dorm_matr_dr.ino is a buttons peer. it is not complete , it has to include the  subscription to the lights on or off  and the RGB control btu that is no issue. 

the issue is in peer_etaj_lumini1. 

if(memory_map[MaCaco_OUT_s +slot_lustra_dorm_mare2] == Souliss_T1n_OnCoil)
pblsh(topic_lustra_dorm_mare2_on);

if(memory_map[MaCaco_OUT_s +slot_lustra_dorm_mare2] == Souliss_T1n_OffCoil)
pblsh(topic_lustra_dorm_mare2_off);

that statement needs to work for both" if (sbscrb(topic_lustra_dorm_mare2_toggle))" or from the app 

hope is not too confusing

thanks 

peer_dorm_matr_pat_dr.ino
main_gateway.ino
20200508_115701.jpg
20200508_115654.jpg
20200508_120109.jpg
20200508_115941.jpg
peer_etaj_lumini_2.ino
peer_etaj_lumini_1.ino

adcciuca

unread,
May 10, 2020, 11:48:00 AM5/10/20
to souliss
Hi Dario.

i think in got it.
 i have added       #define Souliss_T1n_Trigged 0x25 //trigged  in Typicals.H

 and replaced         memory_map[MaCaco_IN_s + slot] = Souliss_T1n_RstCmd;  with 
                               memory_map[MaCaco_IN_s + slot] = Souliss_T1n_Trigged ; all around in  U8 Souliss_Logic_T11(U8 *memory_map, U8 slot, U8 *trigger)   in T1n.cpp.

and in the main program each channel looks like this

if (sbscrb(topic_lum_baie_2_toggle))
     (memory_map[MaCaco_IN_s +slot_lum_baie_2] = Souliss_T1n_ToggleCmd);
         Logic_SimpleLight(slot_lum_baie_2);
                 DigOut(27, Souliss_T1n_Coil,slot_lum_baie_2);



if (memory_map[MaCaco_IN_s + slot_lum_baie_2] == Souliss_T1n_Trigged  )
{
    if(memory_map[MaCaco_OUT_s +slot_lum_baie_2] == Souliss_T1n_OnCoil)
pblsh(topic_lum_baie_2_on);
if(memory_map[MaCaco_OUT_s +slot_lum_baie_2] == Souliss_T1n_OffCoil)
pblsh(topic_lum_baie_2_off);
  memory_map[MaCaco_IN_s + slot_lum_baie_2] = Souliss_T1n_RstCmd;
 }


tested and works fine.  i cant see affecting anything else. Do you see any issues ?

thanks 

Di Maio, Dario

unread,
May 10, 2020, 12:58:20 PM5/10/20
to sou...@googlegroups.com
Nice trick, but sync between the two nodes maybe not guaranteed. If you power off the node with the relay what will happen?

Dario



--
You received this message because you are subscribed to the Google Groups "souliss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to souliss+u...@googlegroups.com.

Di Maio, Dario

unread,
May 10, 2020, 1:05:20 PM5/10/20
to sou...@googlegroups.com
One note, most of the logics returns 1 if the output has changed.

So you can use

if(Souliss_Logic(...)) {

...publish...
}

In this way you don't need to modify the T11.cpp file.

If you want to ensure sync between the nodes, you should periodically publish the values to output nodes.

Dario.


On Sun, 10 May 2020, 17:48 adcciuca <adcc...@gmail.com wrote:

adcciuca

unread,
Nov 20, 2021, 5:51:03 PM11/20/21
to souliss
hi all,
 is there a way to integrate remote  toggle buttons into typicals ?
i have 2 nodes that handle the power switching of the lights  and  all the wall switches publish the toggle topics for the lights to change over.

the "transmiting node " , running on wemos r1

if (DigIn(D6,Souliss_T1n_ToggleCmd,slot_canal_1))
pblsh(topic_canal_1_toggle);
if (sbscrb(topic_canal_1_on))
leds[D6] = (CRGB(200 2, 0));
if (sbscrb(topic_canal_1_off))
leds[D6] = (CRGB(2,200,0));

and the receiving node  , runing on devkit esp32"

 EXECUTEFAST() {                     
        UPDATEFAST();   
                                      
   FAST_50ms() { 
     // ***lustra_dorm_mare1-----canal_1-----conexiune nr21 ----PIN:CONEXIUNE ELECTRICA1****//

if (sbscrb(topic_canal_1_toggle))
                (memory_map[MaCaco_IN_s +slot_canal_1] = Souliss_T1n_ToggleCmd);
                         Logic_SimpleLight(slot_canal_1);
                 DigOut(21, Souliss_T1n_Coil,slot_canal_1);

{
if (memory_map[MaCaco_IN_s + slot_canal_1] == Souliss_T1n_Trigged  )

 if(memory_map[MaCaco_OUT_s +slot_canal_1] == Souliss_T1n_OnCoil)
pblsh(topic_canal_1_on);
else if(memory_map[MaCaco_OUT_s +slot_canal_1] == Souliss_T1n_OffCoil)
pblsh(topic_canal_1_off);


memory_map[MaCaco_IN_s + slot_canal_1] = Souliss_T1n_RstCmd;
}

in T1n .cpp , lights can be switched on or off using either a wall switch or a toggle button . is there any way to add the _toggle ,  _on,  _off  shared topics?
 or can you guide me where to start modifying the T1n.cpp 

something like:

U8 Souliss_Logic_T11_topic(U8 *memory_map,U8 slot,U8 *trigger,topic); 
.
.
.
.


if (memory_map[MaCaco_IN_s + slot] == Souliss_T1n_ToggleCmd)
{
if(memory_map[MaCaco_OUT_s + slot] == Souliss_T1n_OnCoil)
memory_map[MaCaco_OUT_s + slot] = Souliss_T1n_OffCoil; // Switch OFF the output
else if(memory_map[MaCaco_OUT_s + slot] == Souliss_T1n_OffCoil)
memory_map[MaCaco_OUT_s + slot] = Souliss_T1n_OnCoil; // Switch ON the output

i_trigger = Souliss_TRIGGED;
// Reset
//memory_map[MaCaco_IN_s + slot] = Souliss_T1n_RstCmd;
memory_map[MaCaco_IN_s + slot] = Souliss_T1n_Trigged
};


else if subscrb (topic.....toggle 
{
if(memory_map[MaCaco_OUT_s + slot] == Souliss_T1n_OnCoil)
memory_map[MaCaco_OUT_s + slot] = Souliss_T1n_OffCoil; // Switch OFF the output
pblsh (topic off_feedback)

else if(memory_map[MaCaco_OUT_s + slot] == Souliss_T1n_OffCoil)
memory_map[MaCaco_OUT_s + slot] = Souliss_T1n_OnCoil; // Switch ON the output
pblsh(topic off_feedback )

i_trigger = Souliss_TRIGGED;
// Reset
//memory_map[MaCaco_IN_s + slot] = Souliss_T1n_RstCmd;
memory_map[MaCaco_IN_s + slot] = Souliss_T1n_Trigged ;


the main advantage of going in this direction is that the system can be more modular, as control  and action does not have to be on the same board. Further more , publish /subscribe system can be developed to the whole system, 
lets say to close the curtains at night fall,  or  opening the gate when the car is close by. 

adrian 

Di Maio, Dario

unread,
Nov 29, 2021, 2:19:31 PM11/29/21
to sou...@googlegroups.com
Hi Adrian,

probably using RemoteInput function on the remote node will be much easier, the remote node will send the command based on the digital input.

Regards,
Dario.

Reply all
Reply to author
Forward
0 new messages