diff --git a/Functions.md b/Functions.md deleted file mode 100644 index 6cd6ace..0000000 --- a/Functions.md +++ /dev/null @@ -1,80 +0,0 @@ -# Library functions: - -### Explanations: -* Reporting: device needs to send every X number of seconds update of state, or system will mark it as offline -* Control functions have direction Driver->Device and are used to set values -* Status functions have direction Device->Driver and are used as feedback to update values in driver. If not set differently, the default value will be used from driver. - -### Explanation: -1. function - * function identifier - * default reporting time - * value type - * description - -### List of functions: -1. control_power - * cp - * 0 - * bool - * Receives on or off to control output - -1. status_power - * sp - * 30 - * bool - * Feedback to app if output/input is on or off - -1. control_level - * cl - * 0 - * uint 0-10000 - * On device you will get number in this range when set in app - -1. status_level - * sl - * 30 - * uint 0-10000 - * Device returns status of its analog output - -1. status_temperature - * st - * 60 - * float - * Reports back temperature in Degrees Celsius - -1. status_temperature_target - * stt - * 60 - * float - * Report back temperature target in Degrees Celsius - -1. control_temperature_target - * ctt - * 0 - * float - * Will receive temperature setpoint in Degress Celsius - -1. control_color - * cc - * 0 - * uint 0-10000 - * On device you will get number in this range for each color (R,G,B) when set in app - -1. status_color - * sl - * 30 - * uint 0-10000 - * Device returns the status of the current set color - -1. status_motion - * sm - * 30 - * bool - * Feedback to app if motion sensor is triggered - -1. control_identify - * ci - * 0 - * bool - * Will receive 1 if identify is triggered diff --git a/examples/basic_TemperatureTarget_OnOff/basic_TemperatureTarget_OnOff.ino b/examples/basic_Thermostat_OnOff/basic_Thermostat_OnOff.ino similarity index 87% rename from examples/basic_TemperatureTarget_OnOff/basic_TemperatureTarget_OnOff.ino rename to examples/basic_Thermostat_OnOff/basic_Thermostat_OnOff.ino index 14c9e49..d7c9196 100644 --- a/examples/basic_TemperatureTarget_OnOff/basic_TemperatureTarget_OnOff.ino +++ b/examples/basic_Thermostat_OnOff/basic_Thermostat_OnOff.ino @@ -7,7 +7,7 @@ #include "DHT.h" #include "Endpoints/EndpointOnOff.h" -#include "Endpoints/EndpointTemperatureTarget.h" +#include "Endpoints/EndpointThermostat.h" //#define DEBUG @@ -30,7 +30,7 @@ bool last_state = false; HomeControlMagic hcm(deviceName); -EndpointTemperatureTarget endpointTemperatureTarget(&hcm); +EndpointThermostat endpointThermostat(&hcm); EndpointOnOff endpointOnOff(&hcm); DHT dht(DHT_PIN, DHTTYPE); @@ -76,13 +76,13 @@ void setup() pinMode(DEVICE_PIN, OUTPUT); - hcm.addEndpoint(&endpointTemperatureTarget); + hcm.addEndpoint(&endpointThermostat); hcm.addEndpoint(&endpointOnOff); dht.begin(); double temperature = dht.readTemperature(); - endpointTemperatureTarget.setTemperatureTarget(temperature); + endpointThermostat.setTemperatureTarget(temperature); } void loop() @@ -105,17 +105,17 @@ void loop() } else { - endpointTemperatureTarget.setTemperature(temperature); + endpointThermostat.setTemperature(temperature); } #ifdef DEBUG Serial.print("Temperature from sensor: "); - Serial.print(endpointTemperatureTarget.getTemperature()); + Serial.print(endpointThermostat.getTemperature()); Serial.print(" *C "); Serial.println(); Serial.print("Temperature target: "); - Serial.print(endpointTemperatureTarget.getTemperatureTarget()); + Serial.print(endpointThermostat.getTemperatureTarget()); Serial.print(" *C "); Serial.println(); #endif diff --git a/keywords.txt b/keywords.txt new file mode 100644 index 0000000..b1e99ea --- /dev/null +++ b/keywords.txt @@ -0,0 +1,38 @@ +# Syntax Coloring Map For HomeControl-mqtt library + +# Datatypes (KEYWORD1) +HomeControlMagic KEYWORD1 +EndpointOnOff KEYWORD1 +EndpointColor KEYWORD1 +EndpointIdentify KEYWORD1 +EndpointLevel KEYWORD1 +EndpointMotion KEYWORD1 +EndpointTemperature KEYWORD1 +EndpointThermostat KEYWORD1 + +# Methods and Functions (KEYWORD2) +doMagic KEYWORD2 +addEndpoint KEYWORD2 +getState KEYWORD2 +setState KEYWORD2 +setLevel KEYWORD2 +getLevel KEYWORD2 +getColorR KEYWORD2 +getColorG KEYWORD2 +getColorB KEYWORD2 +setTemperature KEYWORD2 +getTemperature KEYWORD2 +setHeatingSetpoint KEYWORD2 +getHeatingSetpoint KEYWORD2 +networkSetSsid KEYWORD2 +networkSetPass KEYWORD2 +networkSetSecure KEYWORD2 +networkSetup KEYWORD2 +networkStart KEYWORD2 +wrapperSetServer KEYWORD2 +wrapperSetUsernamePassword KEYWORD2 +wrapperSetup KEYWORD2 + +# Instances (KEYWORD2) + +# Constants (LITERAL1) diff --git a/library.json b/library.json deleted file mode 100644 index 7d9705d..0000000 --- a/library.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "homecontrol-mqtt", - "keywords": "ethernet, wifi, esp, mqtt, home, automation, smart", - "description": "This library allows you to send and receive MQTT messages with HomeControlAS system.", - "repository": { - "type": "git", - "url": "https://github.com/HomeControlAS/homecontrol-mqtt" - }, - "version": "0.1", - "examples": "examples/*/*.ino", - "frameworks": "arduino", - "platforms": [ - "espressif8266" - ], - "dependencies": - [ - ] -} diff --git a/library.properties b/library.properties index dc059e3..f181d68 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,10 @@ name=homecontrol-mqtt -version=0.1 -author=homecontrol -maintainer=homecontrol +version=1.0.0 +author=Home Control +maintainer=Home Control sentence=A client library for MQTT messaging. paragraph= This library allows you to send and receive MQTT messages with HomeControlAS system. category=Communication url=https://github.com/HomeControlAS/homecontrol-mqtt -architectures=* \ No newline at end of file +architectures=* +depends=PubSubClient \ No newline at end of file diff --git a/src/Endpoints/EndpointTemperatureTarget.cpp b/src/Endpoints/EndpointTemperatureTarget.cpp deleted file mode 100644 index 3ff2c58..0000000 --- a/src/Endpoints/EndpointTemperatureTarget.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "EndpointTemperatureTarget.h" -#include "HomeControlMagic.h" -#include "debugDefines.h" -#include "helperFunctions.h" -#include "printWrapper.h" - -static char* const CONFIG = "temp_tar"; - -EndpointTemperatureTarget::EndpointTemperatureTarget(HomeControlMagic* hcm_ptr) - : Endpoint(hcm_ptr) - , m_temperature(0) -{ - m_config = CONFIG; -} - -void EndpointTemperatureTarget::setTemperature(double temperature) -{ - m_temperature = temperature; -} - -double EndpointTemperatureTarget::getTemperature() -{ - return m_temperature; -} - -void EndpointTemperatureTarget::setTemperatureTarget(double temperature) -{ - m_temperature_target = temperature; -} - -double EndpointTemperatureTarget::getTemperatureTarget() -{ - return m_temperature_target; -} - -void EndpointTemperatureTarget::incomingMessage(char* topic, uint8_t* payload, unsigned int length) -{ -#ifdef ENDPOINT_TEMPERATURE_TARGET_DEBUG - print(F("Incoming message, EndpointTemperatureTarget")); -#endif - - if(lineContains(topic, "ctt")) - { - m_temperature_target = extractDouble(payload, length); - } - - else if(lineContains(topic, "stt")) - { - m_owner->sendMessage("stt", m_temperature_target, m_id); - } - - else if(lineContains(topic, "st")) - { - m_owner->sendMessage("st", m_temperature, m_id); - } -} - -void EndpointTemperatureTarget::sendFeedbackMessage() -{ -#ifdef ENDPOINT_TEMPERATURE_TARGET_DEBUG - print(F("Sending feedback message, EndpointTemperatureTarget")); -#endif - - m_owner->sendMessage("st", m_temperature, m_id); - m_owner->sendMessage("stt", m_temperature_target, m_id); -} \ No newline at end of file diff --git a/src/Endpoints/EndpointThermostat.cpp b/src/Endpoints/EndpointThermostat.cpp new file mode 100644 index 0000000..d8efeb7 --- /dev/null +++ b/src/Endpoints/EndpointThermostat.cpp @@ -0,0 +1,66 @@ +#include "EndpointThermostat.h" +#include "HomeControlMagic.h" +#include "debugDefines.h" +#include "helperFunctions.h" +#include "printWrapper.h" + +static char* const CONFIG = "thrmstt"; + +EndpointThermostat::EndpointThermostat(HomeControlMagic* hcm_ptr) + : Endpoint(hcm_ptr) + , m_temperature(0) +{ + m_config = CONFIG; +} + +void EndpointThermostat::setTemperature(double temperature) +{ + m_temperature = temperature; +} + +double EndpointThermostat::getTemperature() +{ + return m_temperature; +} + +void EndpointThermostat::setHeatingSetpoint(double temperature) +{ + m_heating_setpoint = temperature; +} + +double EndpointThermostat::getHeatingSetpoint() +{ + return m_heating_setpoint; +} + +void EndpointThermostat::incomingMessage(char* topic, uint8_t* payload, unsigned int length) +{ +#ifdef ENDPOINT_THERMOSTAT_DEBUG + print(F("Incoming message, EndpointThermostat")); +#endif + + if(lineContains(topic, "chs")) + { + m_heating_setpoint = extractDouble(payload, length); + } + + else if(lineContains(topic, "shs")) + { + m_owner->sendMessage("shs", m_heating_setpoint, m_id); + } + + else if(lineContains(topic, "st")) + { + m_owner->sendMessage("st", m_temperature, m_id); + } +} + +void EndpointThermostat::sendFeedbackMessage() +{ +#ifdef ENDPOINT_THERMOSTAT_DEBUG + print(F("Sending feedback message, EndpointThermostat")); +#endif + + m_owner->sendMessage("st", m_temperature, m_id); + m_owner->sendMessage("shs", m_heating_setpoint, m_id); +} \ No newline at end of file diff --git a/src/Endpoints/EndpointTemperatureTarget.h b/src/Endpoints/EndpointThermostat.h similarity index 55% rename from src/Endpoints/EndpointTemperatureTarget.h rename to src/Endpoints/EndpointThermostat.h index a371284..e3beacf 100644 --- a/src/Endpoints/EndpointTemperatureTarget.h +++ b/src/Endpoints/EndpointThermostat.h @@ -2,22 +2,22 @@ #include "Endpoint.h" -class EndpointTemperatureTarget : public Endpoint +class EndpointThermostat : public Endpoint { public: - EndpointTemperatureTarget(HomeControlMagic* hcm_ptr); + EndpointThermostat(HomeControlMagic* hcm_ptr); virtual void sendFeedbackMessage(); virtual void incomingMessage(char* topic, uint8_t* payload, unsigned int length); virtual void setTemperature(double temperature); - virtual void setTemperatureTarget(double temperature); + virtual void setHeatingSetpoint(double temperature); virtual double getTemperature(); - virtual double getTemperatureTarget(); + virtual double getHeatingSetpoint(); protected: double m_temperature; - double m_temperature_target; + double m_heating_setpoint; }; \ No newline at end of file diff --git a/src/debugDefines.h b/src/debugDefines.h index 14df0b0..b73e54f 100644 --- a/src/debugDefines.h +++ b/src/debugDefines.h @@ -7,7 +7,7 @@ #define HCM_DEBUG #define ENDPOINT_DEBUG #define ENDPOINT_ZERO_DEBUG -#define ENDPOINT_TEMPERATURE_TARGET_DEBUG +#define ENDPOINT_THERMOSTAT_DEBUG #define ENDPOINT_TEMPERATURE_DEBUG #define ENDPOINT_ON_OFF_DEBUG #define ENDPOINT_MOTION_DEBUG @@ -21,7 +21,7 @@ // #define HCM_DEBUG // #define ENDPOINT_DEBUG // #define ENDPOINT_ZERO_DEBUG -// #define ENDPOINT_TEMPERATURE_TARGET_DEBUG +// #define ENDPOINT_THERMOSTAT_DEBUG // #define ENDPOINT_TEMPERATURE_DEBUG // #define ENDPOINT_ON_OFF_DEBUG // #define ENDPOINT_MOTION_DEBUG