Configuration with finder 26.02

Good evening guys I’m here to ask you for advice on how to set openhab3,
I have a configuration with a relay finder 26.02 so on one pin I have the status of the light on the other I have the relay that activates it with a pulse.
how should i ect everything on openhab3?
if set as a switch, the light turns on but the timane status is always off

You might find the ideas in this thread helpful

The important part is using two Items -one to represent on/off state, one for control pulses.

How do I merge the status to the relay into one control?

Don’t. Don’t put the “pulse” Item on your GUI at all, it is of no use there. Only show your “status” Item.

Okay, but if I don’t show the pulse I can’t control it

You may have missed the idea of a rule being necessary. The ‘real’ Item shows only status, but you can send it commands from GUI or other rules. Nothing happens. But you can create a rule that listens for commands to this ‘real’ Item, and acts by sending commands to the ‘pulse’ Item. This the part that simulates button-pushing and activates your device. Don’t forget it must also simulate button-releasing.

You don’t need to see the pulse Item anywhere to have it worked by a rule.

Thank you. how can i create the rule?
I tried like this but it doesn’t work …

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: NodemcuStudio_StatoLuceStudio
    type: core.ItemStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/javascript
      script: >-
        var Exec = Java.type("org.openhab.core.model.script.actions.Exec");

        var logger = Java.type("org.slf4j.LoggerFactory").getLogger("org.openhab.rule." + ctx.ruleUID);

        var HttpUtil = Java.type("org.openhab.core.io.net.http.HttpUtil")

        var switchluce = itemRegistry.getItem('NodemcuStudio_StatoLuceStudio').getState();

        logger.info("posizione switch " + switchluce);

        if (switchluce == 'ON'){

        logger.info("If ON");
          ReleLuce_LuceStudio.sendCommand(ON)
        logger.info("Accendi richiesta " + HttpUtil);

        } else if (switchluce == 'OFF'){
          ReleLuce_LuceStudio.sendCommand(ON)
        logger.info("Spegni richiesta " + HttpUtil);

        }
    type: script.ScriptAction

We don’t know what any of your Items represent. If you expect the rule to do something when you send a command, you would need to change the rule trigger. If you want help, we’ll need more than “doesn’t work”. You can find out if the rule runs at all, for example, or just doesn’t do what you expected. Making log messages from your rule are really helpful to see progress and internal values. You’ve done that but not told us the results - “no results” tells us something too. Looking in your openhab.log for messages, and your events.log to see what is done, might help.

I don’t use javascript rules, but you should be able to see the idea here

You must do the “un-pushing” of your simulated pushbutton too. You might do that with a timer from rule, or by Item ‘expire’ property, or like I show there, by a rule that sees when the light status changes and “stops pushing the button”.

thank you
solution:

var Exec = Java.type("org.openhab.core.model.script.actions.Exec");
var logger = Java.type("org.slf4j.LoggerFactory").getLogger("org.openhab.rule." + ctx.ruleUID);
var HttpUtil = Java.type("org.openhab.core.io.net.http.HttpUtil")
var switchluce = itemRegistry.getItem('NodemcuStudio_StatoLuceStudio').getState();

logger.info("posizione switch " + switchluce + " Evento= " + event.itemCommand);
if (event.itemCommand == 'ON' && switchluce == 'OFF'){
      logger.info("If ON OFF");
      events.sendCommand("NodemcuStudio_LuceStudio",ON)   
    
} else if (event.itemCommand == 'OFF' && switchluce == 'ON') {
   logger.info("If OFF ON");
     events.sendCommand("NodemcuStudio_LuceStudio",ON)
     
   }        // else already in requested state
1 Like

Don’t forget the “un-push” part after the required action.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.