Comments (6)
To be honest this sounds more like a new plugin as moving all the logic to the device basically removes the need for all the other bits. Your keep alive watchdog is basically recreating the idle timer on device.
from octoprint-tasmota.
I'm not looking for idle shutdown. Idle shutdown kills power when not printing. I want power killed when the system fails to check in due to a failure or lock up which your plugin can't detect, and absolutely not when merely idle.
Please read the entire message. I know it's a lot but it very carefully explains what I need and why, as well as what it adds, and it solves two open issues.
If I implemented a plugin to do what I want, it would include about 75% of your plugin as well, and idle shutdown is completely counter to my desires. That's a lot more than two additional options on timers you're already running to send commands to devices you're already supporting via methods you already have in place, and the features I'm requesting compliment your features without either re-implementing or contradicting existing features in any way.
from octoprint-tasmota.
I'll try to pitch this one other way.
Let's say your Pi locks up. Doesn't matter why.
What does your plugin do? Nothing.
My suggestion is security through regular checkin. Watchdog, keep-alive, whatever you want to call it.
My suggestion requests power for a safe duration; shorter while hot and printing, longer while idle/cold. If safe duration passes without check in, power is disabled.
This adds safety to existing features, because if a power brown out or surge kills your Pi and your printer MOSFET at the same time - which is not unlikely - it gets shut down assuming the Tasmota device survived.
The other features offered are still desirable and in some cases required, such as your existing temperature runaway. I'm aiming to add lockup/watchdog protection to that.
from octoprint-tasmota.
I see your point about not being a separate plugin now. If you could provide the rulesets and what not to set this up on a tasmota device that would be helpful for me for development purposes. If you could provide how to also add the ruleset via API calls that would be a huge help as well, because I do like the idea of being able to click a button in the settings and have them automatically added to a device.
from octoprint-tasmota.
Sweet, no problem. Glad to hear the idea interests you!
On the Tasmota device, it's shockingly easy - for ESP8266 devices. ESP32 devices use Berry scripting instead of Rules, but I feel like 90% of power-control related devices are ESP8266. If you want ESP32 support, I could be convinced to write one up and test it. I'm also happy to guinea pig any changes or testing branches, if that helps.
Manual set-up;
- Pull up Tasmota UI, click Console
- Add the keepalive rule. There are three rule slots. I'm using slot 1 for the keepalive, rule2 and rule3 are in use for other functions, in my setup -- might be wise to allow the user to pick which rule slot it targets, or at minimum warn them about klobbering.
rule1 ON Event#KEEPALIVE DO RuleTimer1 %value% ENDON ON RULES#Timer=1 DO Backlog Power1 Off; Power2 Off ENDON
- The only way to check if the rule exists (easily) is to query it with no rule, IE,
rule1
-- it should return a JSON packet containing the rule, as well as other data;
02:01:24.234 RSL: RESULT = {"Rule1":{"State":"ON","Once":"OFF","StopOnError":"OFF","Length":104,"Free":407,"Rules":"ON Event#KEEPALIVE DO RuleTimer1 %value% ENDON ON RULES#Timer=1 DO Backlog Power1 Off; Power2 Off ENDON"}}
- Make sure Rule1 is enabled;
rule1 1
- (Optional; advised) Make sure Rule 1 is not set to One-Shot mode;
rule1 4
For API-based setup, the commands are the same, just sent to the HTTP API endpoint as a query.
For example http://<ip>/cm?cmnd=Event%20KEEPALIVE=1
is the same as sending Event Keepalive=1
from the device's Console.
I don't speak Python but I believe that's requests.get('http://<ip>/cm',params={'cmnd':'Event KEEPALIVE=1'})
-- though I seriously doubt that's exactly accurate.
A quick breakdown of the rule, and how it works (in case you don't speak Tasmota Rules);
ON Event#KEEPALIVE DO RuleTimer1 %value% ENDON
-- When the unit receives the command "event KEEPALIVE " it will trigger this rule, setting the first rule timer to whatever number it received.ON RULES#Timer=1 DO
When the first rule timer triggersBacklog
Run a sequence of commands instead of just onePower1 Off; Power2 Off
I'm using two channels (one for each 24v power supply)ENDON
End of command- To change the rule slot, obviously
rule2
orrule3
- To change the timer slot, the command
RuleTimer<x>
and the triggerRULES#TIMER=<x>
must be updated. There are 8 available timers on Tasmota firmware. They can be set from 0 to 65535. Set to 0 to clear without triggering. - https://tasmota.github.io/docs/Commands/#rules
- https://tasmota.github.io/docs/Rules/
Interacting with this rule is cake;
- Send
Event KEEPALIVE=120
and it will stay on for 120 seconds. I recommend sending MUCH more often than required, in case a packet gets dropped for whatever reason. My intent was to run the timer for ~125sec and send it every ~30sec. This means it can miss checking in three times, with a 5 second variance window, before the unit shuts off power. Paranoid users may wish to shorten these windows, but I feel the "worst case" will take much more than two minutes. - Send
Event KEEPALIVE=0
and it will disable the watchdog. It will -not- turn off power if a watchdog timer is already running. This could be used for Maintenance work, or to ensure the watchdog only runs while printing if that's the desire.
Obviously if the watchdog is running when the user shuts down their Pi, it will power down. This is actually a plus, BUT if their Keepalive is set too short, the Pi might take longer to shutdown than provided. May want to limit the lower end of that setting, or warn of this. Also, a user could NOT enable the watchdog during print/idle, but trigger it explicitly before shutting down, to use it as -only- a "shutdown poweroff" function. That's how mine is used right now, lol, since I don't have a plugin to poke it regularly.
Sorry if this was a lot of ramble, I'm trying to be thorough. I'm more than willing to provide anything else to help.
from octoprint-tasmota.
Oh also; to trigger the rule manually from a proper command line, in case you're less familiar with using Curl to test API endpoints;
curl http://<ip>/cm?cmnd=Event%20KEEPALIVE=120
You can check the running rule timers during development by just sending ruletimer
-- reset all timers with ruletimer 0
from octoprint-tasmota.
Related Issues (20)
- API support for status HOT 6
- Power off during printing HOT 4
- issue when upgrading to octoprint 1.8.1 HOT 5
- Theme Support
- switch via API call HOT 4
- Lots of connection errors HOT 2
- Sonoff POW not switching off... HOT 6
- power off on idle not working ? HOT 3
- icon picker doesn't seem to work HOT 9
- S31 Sonoff plug (Tasmota Error... status unknown for the IP) HOT 5
- READINGS DO NOT MATCH plug with athom energy meter HOT 6
- Plugin requires SetOption65 to be 0 to work, but my plug keeps resetting if I do that. HOT 3
- using GCODE for shutdown in .gcode files fails HOT 4
- 'Power off on idle' does not wait for bed to cool HOT 3
- No connection with new device HOT 9
- Issue With Power Monitoring With Blank IDX HOT 1
- Power off on idle not working on MK4 HOT 4
- Use separate scale/graph for power/cost HOT 7
- 'power off after print finishes' checkbox. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from octoprint-tasmota.