This commit is contained in:
Gašper Dobrovoljc 2023-05-31 19:22:54 +02:00
parent 7ff8935a6a
commit ae7151126e
No known key found for this signature in database
GPG Key ID: 0E7E037018CFA5A5

View File

@ -120,42 +120,56 @@
#define PIN_52_RESERVED 52 // reserved by W5x00 Shield on MEGA
#define PIN_53_RESERVED 53 // reserved by W5x00 Shield on MEGA
// WC
#define PIN_WC_LUC_1 24
#define PIN_WC_LUC_2 25
#define PIN_WC_ALARM 26
#define PIN_WC_TEMPHUM 27
// Analog Pins
#define PIN_WATER_1 A0 // SmartThings Capability "Water Sensor"
#define PIN_WATER_2 A1 // SmartThings Capability "Water Sensor"
#define PIN_ILLUMINANCE_1 A2 // SmartThings Capability "Illuminance Measurement"
#define PIN_ILLUMINANCE_2 A3 // SmartThings Capability "Illuminance Measurement"
#define PIN_VOLTAGE_1 A4 // SmartThings Capability "Voltage Measurement"
#define PIN_VOLTAGE_2 A5 // SmartThings Capability "Voltage Measurement"
#define PIN_SMOKE_3 A8 // SmartThings Capability "Smoke Detector"
#define PIN_SMOKE_4 A9 // SmartThings Capability "Smoke Detector"
// Hodnik
#define PIN_HODNIK_VRATA 28
#define PIN_HODNIK_LUC_1 29
#define PIN_HODNIK_LUC_2 30
#define PIN_HODNIK_LUC_3 31
#define PIN_HODNIK_LUC_4 32
#define PIN_HODNIK_ZVONEC 33
#define PIN_HODNIK_LED_OMARA 34
#define PIN_HODNIK_LED_STROP 35
#define PIN_HODNIK_ZUNAJ_VHOD 36
#define PIN_HODNIK_SENZOR_STOPNISCE 37
#define PIN_HODNIK_SENZOR_VRATA 38
// Digital Pins
#define PIN_TEMPERATUREHUMIDITY_1 \
22 // SmartThings Capabilities "Temperature Measurement" and "Relative
// Humidity Measurement"
#define PIN_TEMPERATUREHUMIDITY_2 \
23 // SmartThings Capabilities "Temperature Measurement" and "Relative
// Humidity Measurement"
#define PIN_MOTION_1 24 // SmartThings Capability "Motion Sensor"
#define PIN_MOTION_2 25 // SmartThings Capability "Motion Sensor"
#define PIN_CONTACT_1 26 // SmartThings Capability "Contact Sensor"
#define PIN_CONTACT_2 27 // SmartThings Capability "Contact Sensor"
#define PIN_SWITCH_1 28 // SmartThings Capability "Switch"
#define PIN_SWITCH_2 29 // SmartThings Capability "Switch"
#define PIN_TIMEDRELAY_1 30 // SmartThings Capability "Relay Switch"
#define PIN_TIMEDRELAY_2 31 // SmartThings Capability "Relay Switch"
#define PIN_SMOKE_1 32 // SmartThings Capability "Smoke Detector"
#define PIN_SMOKE_2 33 // SmartThings Capability "Smoke Detector"
#define PIN_ALARM_1 34 // SmartThings Capability "Alarm"
#define PIN_ALARM_2 40 // SmartThings Capability "Alarm"
#define PIN_STROBE_2 41 // SmartThings Capability "Alarm"
#define PIN_CO_1 42 // SmartThings Capability "Carbon Monoxide Detector"
#define PIN_CO_2 43 // SmartThings Capability "Carbon Monoxide Detector"
// Jedilnica
#define PIN_JEDILNICA_TIPKA_1 40
#define PIN_JEDILNICA_TIPKA_2 41
#define PIN_JEDILNICA_TIPKA_3 42
#define PIN_JEDILNICA_TIPKA_4 43
#define PIN_JEDILNICA_TIPKA_5 44
#define PIN_JEDILNICA_LUC_1 45
#define PIN_JEDILNICA_LUC_2 46
// Dimmer Switch Pins
#define PIN_DIMMERLEVEL_1 \
44 // SmartThings Capability "Switch Level" NOTE: MUST BE A PWM CAPABLE PIN!
#define PIN_DIMMERSWITCH_1 45 // SmartThings Capability "Switch"
#define PIN_DIMMERLEVEL_2 \
46 // SmartThings Capability "Switch Level" NOTE: MUST BE A PWM CAPABLE PIN!
#define PIN_DIMMERSWITCH_2 47 // SmartThings Capability "Switch"
// Dnevna
#define PIN_DNEVNA_LUC_VTICNICA 48
#define PIN_DNEVNA_TEMPHUM_PODSTREHA 49
#define PIN_DNEVNA_TEMPHUM 50
// Garage Door Pins
#define PIN_DOORCONTROL_CONTACT_1 35 // SmartThings Capabilty "Door Control"
#define PIN_DOORCONTROL_RELAY_1 36 // SmartThings Capabilty "Door Control"
#define PIN_DOORCONTROL_CONTACT_2 37 // SmartThings Capabilty "Door Control"
#define PIN_DOORCONTROL_RELAY_2 38 // SmartThings Capabilty "Door Control"
// Otroška soba
#define PIN_OTROSKA_LUC_1 51
#define PIN_OTROSKA_LUC_2 52
// Pushbutton Pins
#define PIN_BUTTON1 48 // SmartThings Capabilty Button / Holdable Button
#define PIN_BUTTON2 49 // SmartThings Capabilty Button / Holdable Button
//******************************************************************************************
// W5x00 Ethernet Shield Information
@ -163,37 +177,29 @@
// NOTE - If your shield came with a MAC address sticker - please use that MAC
// address!
byte mac[] = {0x06, 0x02, 0x03, 0x04,
0x05, 0x06}; // MAC address, leave first octet 0x06, change others
// to be unique // <---You must edit this line!
// MAC address, leave first octet 0x06, change others to be unique
byte mac[] = {0x06, 0x02, 0x03, 0x04, 0x05, 0x06};
// Arduino device IP Address
IPAddress ip(192, 168, 88, 206);
// Router gateway
IPAddress gateway(192, 168, 88, 1);
// LAN subnet mask
IPAddress subnet(255, 255, 255, 0);
// DNS server
IPAddress dnsserver(192, 168, 88, 1);
// port to run the http server on
const unsigned int serverPort = 8090;
IPAddress ip(192, 168, 88, 206); // Arduino device IP Address // <---You must
// edit this line!
IPAddress gateway(192, 168, 88, 1); // router gateway // <---You must edit this
// line!
IPAddress subnet(255, 255, 255, 0); // LAN subnet mask // <---You must edit
// this line!
IPAddress dnsserver(192, 168, 88,
1); // DNS server // <---You must edit this line!
const unsigned int serverPort = 8090; // port to run the http server on
// Smartthings Hub Information
// IPAddress hubIp(192, 168, 1, 149); // smartthings hub ip // <---You
// must edit this line! const unsigned int hubPort = 39500; // smartthings hub
// port
IPAddress hubIp(192, 168, 88, 251);
// smartthings hub ip // <---You must edit this line!
const unsigned int hubPort = 39501; // smartthings hub port
// Hubitat Hub Information
// hubitat hub ip
IPAddress hubIp(192, 168, 88, 251);
// hubitat hub port
const unsigned int hubPort = 39501;
// IPAddress hubIp(192, 168, 1, 145); // hubitat hub ip // <---You
// must edit this line! const unsigned int hubPort = 39501; // hubitat hub
// port
//******************************************************************************************
// st::Everything::callOnMsgSend() optional callback routine. This is a sniffer
@ -245,41 +251,64 @@ void setup() {
// specific use case in the ST Phone Application.
//******************************************************************************************
// Polling Sensors
static st::IS_Contact wcLuc1(F("tipka_wc_luc_1"), PIN_WC_LUC_1, LOW);
static st::IS_Contact wcLuc2(F("tipka_wc_luc_2"), PIN_WC_LUC_2, LOW);
static st::IS_Contact wcAlarm(F("tipka_wc_alarm"), PIN_WC_ALARM, LOW);
static st::PS_TemperatureHumidity wcTempHum(
F("wc_temp_hum"), 60, 40, PIN_WC_TEMPHUM,
st::PS_TemperatureHumidity::DHT22, "wc_temp", "wc_hum");
static st::IS_Contact hodnikZvonecTipkalo(F("hodnik_zvonec_tipkalo"),
PIN_HODNIK_ZVONEC, LOW);
static st::IS_Contact jedilnicaTipka1(F("jedilnica_tipka_1"),
PIN_JEDILNICA_TIPKA_1, LOW);
static st::IS_Contact jedilnicaTipka2(F("jedilnica_tipka_2"),
PIN_JEDILNICA_TIPKA_2, LOW);
static st::IS_Contact jedilnicaTipka3(F("jedilnica_tipka_3"),
PIN_JEDILNICA_TIPKA_3, LOW);
static st::IS_Contact jedilnicaTipka4(F("jedilnica_tipka_4"),
PIN_JEDILNICA_TIPKA_4, LOW);
static st::IS_Contact jedilnicaTipka5(F("jedilnica_tipka_5"),
PIN_JEDILNICA_TIPKA_5, LOW);
static st::IS_Contact otroskaTipka1(F("otroska_tipka_1"), PIN_OTROSKA_LUC_1,
LOW);
static st::IS_Contact otroskaTipka2(F("jedilnica_tipka_5"), PIN_OTROSKA_LUC_2,
LOW);
static st::PS_Water sensor1(F("water1"), 60, 0, PIN_WATER_1, 200);
static st::PS_Water sensor2(F("water2"), 60, 10, PIN_WATER_2, 200);
static st::PS_Illuminance sensor3(F("illuminance1"), 60, 20,
PIN_ILLUMINANCE_1, 0, 1023, 0, 1000);
static st::PS_Illuminance sensor4(F("illuminance2"), 60, 30,
PIN_ILLUMINANCE_2, 0, 1023, 0, 1000);
static st::PS_TemperatureHumidity sensor5(
F("temphumid1"), 60, 40, PIN_TEMPERATUREHUMIDITY_1,
st::PS_TemperatureHumidity::DHT22, "temperature1", "humidity1");
static st::PS_TemperatureHumidity sensor6(
F("temphumid2"), 60, 50, PIN_TEMPERATUREHUMIDITY_2,
st::PS_TemperatureHumidity::DHT22, "temperature2", "humidity2");
static st::PS_Voltage sensor7(F("voltage1"), 60, 55, PIN_VOLTAGE_1, 0, 1023,
0, 5000);
static st::PS_Voltage sensor8(F("voltage2"), 60, 57, PIN_VOLTAGE_2, 0, 1023,
0, 5000);
static st::PS_MQ2_Smoke sensor23(F("smoke3"), 10, 3, PIN_SMOKE_3, 300);
static st::PS_MQ2_Smoke sensor24(F("smoke4"), 10, 5, PIN_SMOKE_4, 300);
// Interrupt Sensors
static st::IS_Motion sensor9(F("motion1"), PIN_MOTION_1, HIGH, false, 500);
static st::IS_Motion sensor10(F("motion2"), PIN_MOTION_2, HIGH, false, 500);
static st::IS_Contact sensor11(F("contact1"), PIN_CONTACT_1, LOW, true, 500);
static st::IS_Contact sensor12(F("contact2"), PIN_CONTACT_2, LOW, true, 500);
static st::IS_Smoke sensor13(F("smoke1"), PIN_SMOKE_1, HIGH, true, 500);
static st::IS_Smoke sensor14(F("smoke2"), PIN_SMOKE_2, HIGH, true, 500);
static st::IS_DoorControl sensor15(F("doorControl1"),
PIN_DOORCONTROL_CONTACT_1, LOW, true,
PIN_DOORCONTROL_RELAY_1, LOW, true, 1000);
static st::IS_DoorControl sensor16(F("doorControl2"),
PIN_DOORCONTROL_CONTACT_2, LOW, true,
PIN_DOORCONTROL_RELAY_2, LOW, true, 1000);
static st::IS_Button sensor17(F("button1"), PIN_BUTTON1, 1000, LOW, true,
500);
static st::IS_Button sensor18(F("button2"), PIN_BUTTON2, 1000, LOW, true,
500);
static st::IS_CarbonMonoxide sensor19(F("carbonMonoxide1"), PIN_CO_1, HIGH,
true, 500);
static st::IS_CarbonMonoxide sensor20(F("carbonMonoxide2"), PIN_CO_2, HIGH,
true, 500);
// Special sensors/executors (uses portions of both polling and executor
// classes)
static st::S_TimedRelay sensor21(F("relaySwitch1"), PIN_TIMEDRELAY_1, LOW,
true, 3000, 0, 1);
static st::S_TimedRelay sensor22(F("relaySwitch2"), PIN_TIMEDRELAY_2, LOW,
true, 3000, 0, 1);
// Executors
static st::EX_Switch hodnikLuc1(F("hodnik_luc_1"), PIN_HODNIK_LUC_1, LOW);
static st::EX_Switch hodnikLuc2(F("hodnik_luc_2"), PIN_HODNIK_LUC_2, LOW);
static st::EX_Switch hodnikLuc3(F("hodnik_luc_3"), PIN_HODNIK_LUC_3, LOW);
static st::EX_Switch hodnikLuc4(F("hodnik_luc_4"), PIN_HODNIK_LUC_4, LOW);
static st::EX_Switch hodnikLedStropAmbient(F("hodnik_led_strop_ambient"),
PIN_HODNIK_LED_STROP, LOW);
static st::EX_Switch hodnikLucZunajVhod(F("hodnik_luc_zunaj_vhod"),
PIN_HODNIK_ZUNAJ_VHOD, LOW);
static st::EX_Switch hodnikVrataVhod(F("hodnik_vrata_vhod"), PIN_HODNIK_VRATA,
LOW);
static st::EX_Switch executor1(F("switch1"), PIN_SWITCH_1, LOW, true);
static st::EX_Switch executor2(F("switch2"), PIN_SWITCH_2, LOW, true);
static st::EX_Alarm executor3(F("alarm1"), PIN_ALARM_1, LOW, true);
static st::EX_Alarm executor4(F("alarm2"), PIN_ALARM_2, LOW, true,
PIN_STROBE_2);
static st::EX_Switch_Dim executor5(F("dimmerSwitch1"), PIN_DIMMERSWITCH_1,
PIN_DIMMERLEVEL_1, LOW, false);
static st::EX_Switch_Dim executor6(F("dimmerSwitch2"), PIN_DIMMERSWITCH_2,
PIN_DIMMERLEVEL_2, LOW, false);
//*****************************************************************************
// Configure debug print output from each main class
@ -316,29 +345,40 @@ void setup() {
//*****************************************************************************
// Add each sensor to the "Everything" Class
//*****************************************************************************
st::Everything::addSensor(&wcLuc1);
st::Everything::addSensor(&wcLuc2);
st::Everything::addSensor(&wcAlarm);
st::Everything::addSensor(&wcTempHum);
st::Everything::addSensor(&hodnikZvonecTipkalo);
st::Everything::addSensor(&jedilnicaTipka1);
st::Everything::addSensor(&jedilnicaTipka2);
st::Everything::addSensor(&jedilnicaTipka3);
st::Everything::addSensor(&jedilnicaTipka4);
st::Everything::addSensor(&jedilnicaTipka5);
st::Everything::addSensor(&otroskaTipka1);
st::Everything::addSensor(&otroskaTipka2);
st::Everything::addSensor(&sensor1);
st::Everything::addSensor(&sensor2);
st::Everything::addSensor(&sensor3);
st::Everything::addSensor(&sensor4);
st::Everything::addSensor(&sensor5);
st::Everything::addSensor(&sensor6);
st::Everything::addSensor(&sensor7);
st::Everything::addSensor(&sensor8);
st::Everything::addSensor(&sensor9);
st::Everything::addSensor(&sensor10);
st::Everything::addSensor(&sensor11);
st::Everything::addSensor(&sensor12);
st::Everything::addSensor(&sensor13);
st::Everything::addSensor(&sensor14);
st::Everything::addSensor(&sensor15);
st::Everything::addSensor(&sensor16);
st::Everything::addSensor(&sensor17);
st::Everything::addSensor(&sensor18);
st::Everything::addSensor(&sensor19);
st::Everything::addSensor(&sensor20);
st::Everything::addSensor(&sensor21);
st::Everything::addSensor(&sensor22);
st::Everything::addSensor(&sensor23);
st::Everything::addSensor(&sensor24);
//*****************************************************************************
// Add each executor to the "Everything" Class
//*****************************************************************************
st::Everything::addExecutor(&hodnikLuc1);
st::Everything::addExecutor(&hodnikLuc2);
st::Everything::addExecutor(&hodnikLuc3);
st::Everything::addExecutor(&hodnikLuc4);
st::Everything::addExecutor(&hodnikLedStropAmbient);
st::Everything::addExecutor(&hodnikLucZunajVhod);
st::Everything::addExecutor(&hodnikVrataVhod);
st::Everything::addExecutor(&executor1);
st::Everything::addExecutor(&executor2);
st::Everything::addExecutor(&executor3);
st::Everything::addExecutor(&executor4);
st::Everything::addExecutor(&executor5);
st::Everything::addExecutor(&executor6);
//*****************************************************************************
// Initialize each of the devices which were added to the Everything Class