5 Commits

Author SHA1 Message Date
jct
d0f3845dc5 Merge pull request 'Update '.drone.yml'' (#6) from jct-patch-1 into master
Reviewed-on: #6
2020-10-05 07:57:06 +00:00
jct
e9e0c17a8a Update '.drone.yml'
All checks were successful
continuous-integration/drone/pr Build is passing
2020-10-05 07:53:54 +00:00
jct
2966170165 Update '.drone.yml' 2020-10-05 07:50:18 +00:00
6be0baf301 Added logging functionality
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/tag Build is failing
2020-02-22 12:14:38 +01:00
jct
cee415446a Branch name changed for homie
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-01-27 09:34:21 +00:00
3 changed files with 12 additions and 10 deletions

View File

@ -6,7 +6,6 @@ steps:
image: python:3
commands:
- pip install platformio
- pio check
- pio run
- name: upload
image: python:3

View File

@ -5,7 +5,7 @@ framework = arduino
upload_speed=921600
build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY -DVERSION=${sysenv.DRONE_SEMVER}
lib_deps = https://github.com/homieiot/homie-esp8266.git#develop-v3, DHT sensor library for ESPx
lib_deps = https://github.com/homieiot/homie-esp8266.git#develop, DHT sensor library for ESPx, HomieLoggerNode
[env:nodemcu]
board = nodemcu

View File

@ -1,6 +1,10 @@
#include "config.h"
#include <Homie.h>
#include <LoggerNode.h>
LoggerNode LN;
#include "DHTesp.h"
DHTesp dht;
@ -24,12 +28,11 @@ bool powerStateHandler(const HomieRange& range, const String& value)
if(value == "on")
{
OUTPUT_SET(true);
Homie.getLogger() << "Power is on" << endl;
LN.logf(__PRETTY_FUNCTION__, LoggerNode::INFO, "Power ON");
}
else
{
OUTPUT_SET(false);
Homie.getLogger() << "Power is off" << endl;
OUTPUT_SET(false); LN.logf(__PRETTY_FUNCTION__, LoggerNode::INFO, "Power OFF");
}
return true;
@ -45,7 +48,7 @@ bool powerTimerHandler(const HomieRange& range, const String& value)
next_timer_update = millis() + 60*1000;
powerNode.setProperty("timer").send(String(settimer));
powerNode.setProperty("state").send("on");
Homie.getLogger() << "Power is on for " << settimer << "minutes" << endl;
LN.logf(__PRETTY_FUNCTION__, LoggerNode::INFO, "Power on for %d minutes", settimer);
OUTPUT_SET(true);
return true;
}
@ -91,8 +94,7 @@ void loopHandleTemperature()
{
float humidity = dht.getHumidity();
float temperature = dht.getTemperature();
Homie.getLogger() << "Temperature: " << temperature << "°C " << humidity << "% Humidty" << endl;
LN.logf(__PRETTY_FUNCTION__, LoggerNode::DEBUG, "Temperature: %f C Humidity: %f", temperature, humidity);
temperatureNode.setProperty("temperature").send(String(temperature));
temperatureNode.setProperty("humidity").send(String(humidity));
lastTemperatureSent = millis();
@ -107,9 +109,10 @@ void loopHandler()
void setup()
{
Serial.begin(CONFIG_SERIAL_BAUDRATE);
Homie_setFirmware("deskcontrol", VERSION);
Homie.setLoggingPrinter(&Serial);
Serial.begin(CONFIG_SERIAL_BAUDRATE);
Homie.disableResetTrigger();