Jump to content

mschaeffler

Members
  • Posts

    356
  • Joined

  • Last visited

  • Days Won

    23

mschaeffler last won the day on May 2

mschaeffler had the most liked content!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

mschaeffler's Achievements

Rising Star

Rising Star (9/14)

  • One Year In
  • Very Popular Rare
  • Reacting Well
  • Collaborator
  • One Month Later

Recent Badges

131

Reputation

  1. I have installed the device on the top inner side of my window: So it is not visible: in closed state it is inside the window and in open it is on the top outside the visible area. The magnet is also inside of the window on the frame: With this mounting also a tilted window can be detected.
  2. @Luke.Starkiller Do you have an Uni or a PlusUni? I have seen similar things with PlusUni.
  3. I did it several times like this: I put the UNI pcb in a heat shrink tube then I straped it to a Wago 249-116 with a cable tie.
  4. to be sure, you could have 4 diodes 1N400x in series in the supply line.
  5. the main idea is this: a short press on the button or sending "S" to the enum starts a 4min timer and then a warning (short off and some additional time on) two pressed or "D" a longer timer and long press or "L" light for one hour. I have a similar script running on two gen2 devices and just changed the communication to the control system in a RPC style with the virtual enum.
  6. // Konstanten let maxCyclic = 60 * 4; let maxState = { "-": 0, "S": 90*4, "D": 5*60*4, "L": 60*60*4, "w": 1, "W": 12 }; // globale Variablen let switchoffTimer = null; let state = Shelly.getComponentStatus( "enum", 200 ).value; let cntState = 0; let cntCyclic = 0; let mqttPrefix = Shelly.getComponentConfig( "mqtt" ).topic_prefix; function showState() { MQTT.publish( mqttPrefix+"/status/enum:200", "{\"value\":\""+state+"\"}", 1, false ); } function setState(aState) { state = aState; cntState = maxState[aState]; showState(); } function checkState() { if( state !== "-" ) { cntState = cntState - 1; if( cntState <= 0 ) { if( state === "S" || state === "D" || state === "L" ) { switchWarn1(); } else if( state === "w" ) { switchWarn2(); } else { Shelly.call( "Enum.Set", { id:200, value:"-" }, null, null ); } } } } function switchOff() { print( "Output switched off" ); Shelly.call( "Switch.Set", { id:0, on:false }, null, null ); setState( "-" ); } function switchOn(aState) { print( "Output switched on ", aState ); Shelly.call( "Switch.Set", { id:0, on:true }, null, null ); setState( aState ); } function switchWarn1() { print( "Output switched warn 1" ); Shelly.call( "Switch.Set", { id:0, on:false }, null, null ); setState( "w" ); } function switchWarn2() { print( "Output switched warn 2" ); Shelly.call( "Switch.Set", { id:0, on:true }, null, null ); setState( "W" ); } function shortPress() { print( "short press" ); if( state !== "L" ) { switchOn( "S" ); } } function doublePress() { print( "double press" ); if( state !== "L" ) { switchOn( "D" ); } } function longPress() { print( "long press" ); if( state !== "L" ) { switchOn( "L" ); } else { Shelly.call( "Enum.Set", { id:200, value:"-" }, null, null ); } } // Handler Shelly.addEventHandler( function(event,ud) { //print( JSON.stringify(event) ); if( event.name === 'input' && event.id === 0 ) { print( "Input event", event.id ); if( event.info.event === "single_push" ) { Shelly.call( "Enum.Set", { id:200, value:"S" }, null, null ); } else if( event.info.event === "double_push" ) { Shelly.call( "Enum.Set", { id:200, value:"D" }, null, null ); } else if( event.info.event === "long_push" ) { Shelly.call( "Enum.Set", { id:200, value:"L" }, null, null ); } } }, null ); Shelly.addStatusHandler( function(event,ud) { //print( JSON.stringify(event) ); if( event.component === "enum:200" ) { print(event.delta.value); if( event.delta.value === "S" ) { shortPress(); } else if( event.delta.value === "D" ) { doublePress(); } else if( event.delta.value === "L" ) { longPress(); } else if( event.delta.value === "-" ) { switchOff(); } } }, null ); // Main if( state !== "-" ) { Shelly.call( "Enum.Set", { id:200, value:"-" }, null, null ); } else { showState(); } Timer.set( 250, true, function(ud) { if( ++cntCyclic >= maxCyclic ) { cntCyclic = 0; showState(); } checkState(); }, null );
×
×
  • Create New...