version 1.0
This commit is contained in:
@@ -10,11 +10,11 @@ I used relays connected to the raspberry pi to control my heaters, fan and light
|
||||
|
||||
For heating my enclosure I got a $15 [lasko](http://www.amazon.com/gp/product/B003XDTWN2?psc=1&redirect=true&ref_=oh_aui_search_detailpage) inside my encosure. I opened it and added a relay to the mains wire.
|
||||
|
||||
**CAUTION: VOLTAGE ON MAINS WIRE CAN KILL YOU, ONLY ATTEMPT TO DO THIS IF YOU KNOW WHAT YOU ARE DOING, AND DO AT YOUR OWN RISK**
|
||||
**CAUTION: VOLTAGE ON MAINS WIRE CAN KILL YOU, ONLY ATTEMPT TO DO THIS IF YOU KNOW WHAT YOU ARE DOING, AND DO AT YOUR OWN RISK **
|
||||
|
||||
**CAUTION 2: THIS HEATER IS NOT INTENDED TO FUNCTION THIS WAY AND IT MIGHT BE A FIRE HAZARD. DO IT AT YOUR OWN RISK**
|
||||
|
||||
The relays module that I used can be found [here](http://www.amazon.com/gp/product/B0057OC6D8?psc=1&redirect=true&ref_=oh_aui_search_detailpage). You need active-low configuration on it (jumper between JD-VCC).
|
||||
The relays module that I used can be found [here](http://www.amazon.com/gp/product/B0057OC6D8?psc=1&redirect=true&ref_=oh_aui_search_detailpage). Those relays are active low, that means that they will turn on when you put LOW on the output of your pin. In orther to not fry your r-pi connect 3.3v to VCC, 5V to JD-VCC and Ground to GND.
|
||||
|
||||
## Setup
|
||||
|
||||
@@ -60,4 +60,4 @@ Pin 18 connected to the relay that controls the heater
|
||||
|
||||
Those settings are configurable, as well the location of the python scripts to read temperature and humidity.
|
||||
|
||||
You can also enable and disable features off the plugin. For example disable the heater feature.
|
||||
You can also enable and disable features off the plugin. For example disable the heater feature.
|
||||
@@ -52,10 +52,12 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin,
|
||||
self.heaterHandler()
|
||||
|
||||
def heaterHandler(self):
|
||||
command=""
|
||||
if self.enclosureCurrentTemperature<float(self.enclosureSetTemperature) and self._settings.get_boolean(["heaterEnable"]):
|
||||
os.system("sudo echo 0 > /sys/class/gpio/gpio"+str(self._settings.get_int(["heaterPin"]))+"/value")
|
||||
command = "sudo echo 0 > /sys/class/gpio/gpio"+str(self._settings.get_int(["heaterPin"]))+"/value"
|
||||
else:
|
||||
os.system("sudo echo 1 > /sys/class/gpio/gpio"+str(self._settings.get_int(["heaterPin"]))+"/value")
|
||||
command = "sudo echo 1 > /sys/class/gpio/gpio"+str(self._settings.get_int(["heaterPin"]))+"/value"
|
||||
os.system(command)
|
||||
|
||||
#~~ StartupPlugin mixin
|
||||
def on_after_startup(self):
|
||||
@@ -81,7 +83,9 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin,
|
||||
|
||||
@octoprint.plugin.BlueprintPlugin.route("/handleFan", methods=["GET"])
|
||||
def handleFan(self):
|
||||
self._logger.info("Caiu no Fan")
|
||||
if self._settings.get_boolean(["fanEnable"]):
|
||||
self._logger.info("Fan: " + flask.request.values["status"])
|
||||
if flask.request.values["status"] == "on":
|
||||
os.system("sudo echo 0 > /sys/class/gpio/gpio"+str(self._settings.get_int(["fanPin"]))+"/value")
|
||||
else:
|
||||
@@ -129,7 +133,7 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin,
|
||||
return dict(
|
||||
heaterEnable=False,
|
||||
heaterPin=18,
|
||||
fanPin=14,
|
||||
fanPin=23,
|
||||
lightPin=15,
|
||||
dhtPin=4,
|
||||
dhtModel=22,
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Have your plugin's CSS files generated to here.
|
||||
@@ -1 +0,0 @@
|
||||
Put your plugin's javascript files here.
|
||||
@@ -22,8 +22,7 @@ $(function() {
|
||||
};
|
||||
|
||||
self.isConnected = ko.computed(function() {
|
||||
//return self.connection.isOperational();
|
||||
return true;
|
||||
return self.connection.loginState.isUser();
|
||||
});
|
||||
|
||||
self.setTemperature = function(){
|
||||
@@ -81,22 +80,41 @@ $(function() {
|
||||
return "off";
|
||||
}
|
||||
|
||||
self.turnFanOn = function(isON){
|
||||
self.turnFanOn = function(){
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
data: {"status": isON ? "on" : "off"},
|
||||
url: "/plugin/enclosure/getEnclosureTemperature",
|
||||
data: {"status": "on"},
|
||||
url: "/plugin/enclosure/handleFan",
|
||||
async: false
|
||||
});
|
||||
}
|
||||
|
||||
self.turnFanOff = function(){
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
data: {"status": "off"},
|
||||
url: "/plugin/enclosure/handleFan",
|
||||
async: false
|
||||
});
|
||||
}
|
||||
|
||||
self.turnLightOn = function(isON){
|
||||
self.turnLightOn = function(){
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
data: {"status": isON ? "on" : "off"},
|
||||
url: "/plugin/enclosure/getEnclosureTemperature",
|
||||
data: {"status":"on"},
|
||||
url: "/plugin/enclosure/handleLight",
|
||||
async: false
|
||||
});
|
||||
}
|
||||
self.turnLightOff = function(){
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
data: {"status":"off"},
|
||||
url: "/plugin/enclosure/handleLight",
|
||||
async: false
|
||||
});
|
||||
}
|
||||
@@ -112,3 +130,4 @@ $(function() {
|
||||
function isNumeric(n) {
|
||||
return !isNaN(parseFloat(n)) && isFinite(n);
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Put your plugin's LESS files here, have them generated to ../css.
|
||||
@@ -15,12 +15,16 @@
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
<form class="form-horizontal" id="enclosure_settings_temperature">
|
||||
<h4>{{ _('Temperature Sensor') }}</h4>
|
||||
<form class="form-horizontal" style="display: none;" data-bind="visible: settings.plugins.enclosure.heaterPin">
|
||||
Available options are:
|
||||
11 for DHT11
|
||||
22 for DHT22
|
||||
2302 for AM2302
|
||||
Available options are: 11 for DHT11; 22 for DHT22 and 2302 for AM2302
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-enclosure-dhtPin">{{ _('Sensor Pin') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: settings.plugins.enclosure.dhtPin">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-enclosure-dhtModel">{{ _('Sensor Type') }}</label>
|
||||
<div class="controls">
|
||||
|
||||
@@ -33,11 +33,11 @@
|
||||
</tr>
|
||||
</table>
|
||||
<h4>{{ _('Fan') }}</h4>
|
||||
<button type="submit" data-bind="click: turnFanOn(true)" class="btn">Turn on</button>
|
||||
<button type="submit" data-bind="click: turnFanOn(false)" class="btn">Turn off</button>
|
||||
<button type="submit" data-bind="click: turnFanOn, enable: settings.settings.plugins.enclosure.fanEnable && isConnected()" class="btn">Turn on</button>
|
||||
<button type="submit" data-bind="click: turnFanOff, enable: settings.settings.plugins.enclosure.fanEnable && isConnected()" class="btn">Turn off</button>
|
||||
<h4>{{ _('Light') }}</h4>
|
||||
<button type="submit" data-bind="click: turnLightOn(true)" class="btn">Turn on</button>
|
||||
<button type="submit" data-bind="click: turnLightOn(false)" class="btn">Turn off</button>
|
||||
<button type="submit" data-bind="click: turnLightOn, enable: settings.settings.plugins.enclosure.lightEnable && isConnected()" class="btn">Turn on</button>
|
||||
<button type="submit" data-bind="click: turnLightOff, enable: settings.settings.plugins.enclosure.lightEnable && isConnected()" class="btn">Turn off</button>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
Your plugin's translations will reside here. The provided setup.py supports a
|
||||
couple of additional commands to make managing your translations easier:
|
||||
|
||||
babel_extract
|
||||
Extracts any translateable messages (marked with Jinja's `_("...")` or
|
||||
JavaScript's `gettext("...")`) and creates the initial `messages.pot` file.
|
||||
babel_refresh
|
||||
Reruns extraction and updates the `messages.pot` file.
|
||||
babel_new --locale=<locale>
|
||||
Creates a new translation folder for locale `<locale>`.
|
||||
babel_compile
|
||||
Compiles the translations into `mo` files, ready to be used within
|
||||
OctoPrint.
|
||||
babel_pack --locale=<locale> [ --author=<author> ]
|
||||
Packs the translation for locale `<locale>` up as an installable
|
||||
language pack that can be manually installed by your plugin's users. This is
|
||||
interesting for languages you can not guarantee to keep up to date yourself
|
||||
with each new release of your plugin and have to depend on contributors for.
|
||||
|
||||
If you want to bundle translations with your plugin, create a new folder
|
||||
`octoprint_enclosure/translations`. When that folder exists,
|
||||
an additional command becomes available:
|
||||
|
||||
babel_bundle --locale=<locale>
|
||||
Moves the translation for locale `<locale>` to octoprint_enclosure/translations,
|
||||
effectively bundling it with your plugin. This is interesting for languages
|
||||
you can guarantee to keep up to date yourself with each new release of your
|
||||
plugin.
|
||||
Reference in New Issue
Block a user