Beiträge von duncan.gardiner

    but I was after a way of having a LAN connected device as the location of the required control is in my greenhouse and the WiFi drops out to my Sonoff THElite that controls my greenhouse heater (via Home Assistant).

    Hi I had the same issue in my Garage. I live in Portugal so all the homes here are concrete block walls, which Wi-Fi struggles to pass through. In rooms I need Wi-Fi I am using POE driven access points (I use the Unifi eco system, either light ceiling mounted, or AC in Wall mounted where I have LAN sockets available.

    I am using a Shelly 3 Pro in my pool house for the same reasons you've describe. but I could have also added a Unifi external access point out there which would have given me better Wi-Fi coverage around the pool as well as provide a link to my shelly.

    Many ways to skin a cat I guess.

    Take care D

    Is there any way to add an external temperature sensor to the Pro 1PM ?

    Not that I am aware of any add-on's for the pro modules. However I have the need from a temperature sensor as well and have just purchased the Shelly Plus Addon module. This clips onto the shelly plus modules and extends their capabilities. Including the Shelly 1PM plus which is also a 16A relay similar in capability to its bigger brother the Shelly Pro 1PM.

    The Add on Module has the ability to run 3 data inputs (Vcc Data GND). So you could have 3 temperature sensors or a mix of temperature humidity and light sensors all from the one Shelly item.

    As its a smaller formfactor item if you wanted that mounted in a consumer unit (the Shelly Pro's are Din rail mounted so I have assume your requirement here). you'll need to also download the thingy-verse 3d print of the DIN rail mount for the shelly Plus.

    I hope that helps.

    Take care D

    this is the problem, use either LAN or Wifi, not both at the same time.

    Hi this was part of my issue. I had also done a very stupid thing, that was to set a static IP of the same value for both the LAN and Wifi connections. This obviously was causing a network conflict. Then I found another issue was a bad LAN cable from my Patch Panel to my Switch.

    With all of these matters resolved I was able to script what I needed to.

    The Console however is not what I would class as very stable. I have noticed specifically with bad code (I am learning Shelly scripts here so my code is full of errors). the script stills stops without much warning. Only once you have a stable script have I found my script will stay running and I can see outputs more regularly. What this has meant for me, is not coding 10s of lines of code and working through the errors, but rather one element only, try that if that breaks fix it, if that works add a new element. much slower than coding in VS Code and Python in my view.

    I hope my failures help someone else.

    Take care D

    Hi All I believe I have answered my own question.

    The following code links the 3 shelly switches together and allows the manual states of a 3 way On-OFF-On switch to be emulated by the shelly 3 Pro in code. So far the result is loads faster than going via Home Assistant. There are some occasions the shelly presents a small time delay between manual switch operations, but it's far less noticeable than when HA was managing these same conditions.

    CODE I have working:

    [script][/script]

    [script]Shelly.addEventHandler(function (event) { [/script]

    [script] //check if the event source is an input [/script]

    [script] //and if the id of the input is 1 [/script]

    [script] if (event.name === "switch" && event.id === 1) { [/script]

    [script] //use event.info.state to determine the input state [/script]

    [script] //true - input on [/script]

    [script] //false - input off [/script]

    [script] //The print statements help determine where in the code the trigger lands [/script]

    [script] print("Switch ", event.id, " is ", event.info.state ? "on" : "off"); [/script]

    [script]
    [/script]

    [script] print (event.info.state); [/script]

    [script]
    [/script]

    [script] if (event.info.state === false){[/script]

    [script] print("sw1 event state is false"); [/script]

    [script] return ; [/script]

    [script] } else if (event.info.state === true){ [/script]

    [script] print("sw1 event state is true"); [/script]

    [script] Shelly.call("Switch.Set", {"id": 0, "on": true}); [/script]

    [script] } else { [/script]

    [script] print("hit sw1 lese statement"); [/script]

    [script] return ; [/script]

    [script] } [/script]

    [script] } else if (event.name === "switch" && event.id === 2) { [/script]

    [script] //use event.info.state to determine the input state [/script]

    [script] //true - input on [/script]

    [script] //false - input off [/script]

    [script] print("Switch ", event.id, " is ", event.info.state ? "on" : "off"); [/script]

    [script]
    [/script]

    [script] print (event.info.state); [/script]

    [script]
    [/script]

    [script] if (event.info.state === false){ [/script]

    [script] print("sw2 event state is false"); [/script]

    [script] return ; [/script]

    [script] } else if (event.info.state === true){ [/script]

    [script] print("sw2 event state is true"); [/script]

    [script] Shelly.call("Switch.Set", {"id": 0, "on": false}); [/script]

    [script] } else { [/script]

    [script] print("hit sw2 lese statement"); [/script]

    [script] return ; [/script]

    [script] } [/script]

    [script] } else{ [/script]

    [script] return ; [/script]

    [script] } [/script]

    [script]});[/script]

    [script]
    [/script]

    [script][/script]

    I hope this helps someone else out.

    Thanks Duncan

    Hi I am trying to learn to code scripts on a Shelly Pro 3. This device is connected to my network via a LAN cable and Wi-Fi. I notice a few things as I am trying to code scripts locally onto it.

    1. the shelly keeps loosing connection. and takes a while to come back online.

    2. when I start a scrip and then try and use the console in the script editor to see printed output results, the script stops and I see zero in the console.

    only once and a while does the start stay running and I get to see the results.

    can anyone tell me what I am that is causing the Shelly to stop the script constantly?

    Kind regards

    Duncan

    Hi I am new to the shelly community.

    I need a bit of help with some shelly scripting.

    I have a shelly 3 Pro I am using in my pool shed to turn on and off a pool pump. Basic stuff really. I am using Home assistant as my automation server which runs all on and off times that need to be automated. and I was using it to control 2 manual states of the Pump: Manual On (ignores all automations and simply turns the pump on), Manual Off (ignores all automations and simply turns the pump off).

    Both of these states are crucial as I have a third party who cleans my pool and they need the ability to operate the pump independently of any computer controlled schedules.

    While Home assistant can cover the manual on and manual off scenarios, I have found two things which I am hoping scripting the same locally on the shelly device itself will resolve.

    1, there is a significant delay while the shelly communicates to Home Assistant and then Home assistant replies with the correct command. This delay causes confusion at the physical switch. and I have found the pool guy turning the switch on and off repeatedly scratching his head wondering why nothing is happening.

    2. if the shelly drops internet connection the manual switching conditions I have set in Home assistant stops working.

    The physical layout looks like this:

    Output zero of the shelly is the physical relay for the pump.

    Output 1 is connected to a green LED lamp which is displayed in the pump house

    Output 2 is connected to a Red LED lamp which is displayed in the pump house

    Input zero is not wired

    Input 1 is wired to one side of a physical 3 way switch (On-Off-On) connected to the shelly in the pump house.

    Input 2 is wired to the other switch of the same 3 way switch (On-Off-On) connected to the shelly in the pump house.

    In Home assistant code what happens when the physical 3 way switch is operated.

    If shelly Input 1 is on - turn on shelly Output zero

    If shelly Input 2 is on - turn Off shelly Output zero. Because this is a physical 3 way switch, when one position is chosen, the others are physically turned off.

    if the 3rd position of the switch is chosen. this sets a condition (Input 1 and 2 are both off) Home Assistant checks for, before it allows any automated timings to start the pump by turning on output zero, or stop the pump by turn off output zero.

    Shelly Script goal.

    My goal is to replace this same code from Home assistant as a script on the Shelly itself.

    here is where I have got with my shelly code so far.

    [script] [/script]

    [script]Shelly.addEventHandler(function (event) { [/script]

    [script]//check if the event source is an input [/script]

    [script]//and if the id of the input is 1 [/script]

    [script]if (event.name === "input" && event.id === 1 && event.info.state === true) { [/script]

    [script]//use event.info.state to determine the input state [/script]

    [script]//true - input on [/script]

    [script]//false - input off [/script]

    [script] Shelly.call("Switch.Set", "{ id: 0 " + Settings.Relay + ", on:" + JSON.stringify(newStatus) + "}", null, null); [/script]

    [script]} else if (event.name === "input" && event.id === 2 && event.info.state === true) { [/script]

    [script] Shelly.call("Switch.Set", "{ id: 0 " + Settings.Relay + ", on:" + JSON.stringify(newStatus) + "}", null, null); [/script]

    [script]} else{ [/script]

    [script] print("neither input is on, no change [/script]

    [script]} [/script]

    [script]}); [/script]

    [script][/script]

    My Web interface on my shelly keeps dropping out so I am having trouble getting results and or errors from my scripting returned. Can someone who knows take a look and establish if I am heading in the correct direction with this code?

    To pre-empt the question why am I using a Shelly 3 for this. that is because its the only shelly I could find which has the ability to drive the 3 switch conditions I need:

    Manual on

    Manual off

    Fully Automated.

    Kind regards

    Duncan