Multisensor Multiactuator Sketch / Testboard - tested with FHEM Controller
-
Hi,
because I needed a test board with lots of sensors and getting used to do MySensor Sketches as well as FHEM Controller configuration. This is what I came up with:
My Testboard includes:
Sensors:
- Temperature - Thermoresistor - PIN A3
- Temperature - Dallas DS1820 - PIN 6
- Lightlevel - Photoresistor - PIN A0
Switches:
- 2x Pushbuttons - PIN 5 and A4
- Magnet Switch - PIN 7
Actuators:
The Actuators can be switched on normally (by sending 0 or 1) or can do something predifined (by sending 2 or 3).- 2x LEDs - PIN 3 and PIN 4
- Piezo Buzzer - PIN A5
This is how it looks:
The MySensors Code:
The code is very simple, to make it easy for beginners like me, making adjustments and understanding what happens.#include <MySensor.h> #include <SPI.h> MySensor gw; // Child ID s - Triggers - Buttons, Motion Sensors... #define TRIGGER1_ID 1 // Trigger 1 #define TRIGGER2_ID 2 // Trigger 2 #define TRIGGER3_ID 3 // Trigger 3 /* #define TRIGGER4_ID 4 // Trigger 4 #define TRIGGER5_ID 5 // Trigger 5 #define TRIGGER6_ID 6 // Trigger 6 #define TRIGGER7_ID 7 // Trigger 7 #define TRIGGER8_ID 8 // Trigger 8 #define TRIGGER9_ID 9 // Trigger 9 */ // Child ID s - Actuators - Relays, LEDs,... #define ACTUATOR1_ID 11 // Actuator 1 - LED Orange #define ACTUATOR2_ID 12 // Actuator 2 - LED Red #define ACTUATOR3_ID 13 // Actuator 3 - PIEZO /* #define ACTUATOR4_ID 14 // Actuator 4 #define ACTUATOR5_ID 15 // Actuator 5 #define ACTUATOR6_ID 16 // Actuator 6 #define ACTUATOR7_ID 17 // Actuator 7 #define ACTUATOR8_ID 18 // Actuator 8 #define ACTUATOR9_ID 19 // Actuator 9 */ // Child ID s - Continuous Sensors - Temperature Sensors, Lightlevel Sensors,... #define SENSOR1_ID 21 // Sensor 1 #define SENSOR2_ID 22 // Sensor 2 #define SENSOR3_ID 23 // Sensor 3 /* #define SENSOR4_ID 24 // Sensor 4 #define SENSOR5_ID 25 // Sensor 5 #define SENSOR6_ID 26 // Sensor 6 #define SENSOR7_ID 27 // Sensor 7 #define SENSOR8_ID 28 // Sensor 8 #define SENSOR9_ID 29 // Sensor 9 */ //----------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------- // DEFINITIONS //----------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------ // Triggers - Triggers - Triggers - Triggers - Triggers - Triggers //------------------------------------------------------------------------ // DEFINITIONS - Push Buttons, Door Sensors,... #include <Bounce2.h> // Trigger PINS - Digital PIN -> Button -> GND #define TRIGGER1_PIN 5 #define TRIGGER2_PIN 18 // A4 #define TRIGGER3_PIN 7 /* #define TRIGGER4_PIN 7 #define TRIGGER5_PIN 7 #define TRIGGER6_PIN 7 #define TRIGGER7_PIN 7 #define TRIGGER8_PIN 7 #define TRIGGER9_PIN 7 */ // Bounce Bounce debouncer1 = Bounce(); Bounce debouncer2 = Bounce(); Bounce debouncer3 = Bounce(); /* Bounce debouncer4 = Bounce(); Bounce debouncer5 = Bounce(); Bounce debouncer6 = Bounce(); Bounce debouncer7 = Bounce(); Bounce debouncer8 = Bounce(); Bounce debouncer9 = Bounce(); */ // MyMessage MyMessage msg01(TRIGGER1_ID,V_TRIPPED); MyMessage msg02(TRIGGER2_ID,V_TRIPPED); MyMessage msg03(TRIGGER3_ID,V_TRIPPED); /* MyMessage msg04(TRIGGER4_ID,V_TRIPPED); MyMessage msg05(TRIGGER5_ID,V_TRIPPED); MyMessage msg06(TRIGGER6_ID,V_TRIPPED); MyMessage msg07(TRIGGER7_ID,V_TRIPPED); MyMessage msg08(TRIGGER8_ID,V_TRIPPED); MyMessage msg09(TRIGGER9_ID,V_TRIPPED); */ // Some Variables int oldTrigValue1=-1; int oldTrigValue2=-1; int oldTrigValue3=-1; /* int oldTrigValue4=-1; int oldTrigValue5=-1; int oldTrigValue6=-1; int oldTrigValue7=-1; int oldTrigValue8=-1; int oldTrigValue9=-1; */ //------------------------------------------------------------------------ // Actuators - Actuators - Actuators - Actuators - Actuators - Actuators //------------------------------------------------------------------------ // DEFINITIONS - LEDs, Relays, ... // Actuators PINS - DIGITAL PIN to Actuator #define ACTUATOR1_PIN 3 #define ACTUATOR2_PIN 4 #define ACTUATOR3_PIN 19 /* #define ACTUATOR1_PIN 7 #define ACTUATOR2_PIN 7 #define ACTUATOR3_PIN 7 #define ACTUATOR1_PIN 7 #define ACTUATOR2_PIN 7 #define ACTUATOR3_PIN 7 */ #define ACTUATOR_ON 1 #define ACTUATOR_OFF 0 bool state; //------------------------------------------------------------------------ // Sensors - Sensors - Sensors - Sensors - Sensors - Sensors - Sensors //------------------------------------------------------------------------ // DEFINITIONS - Temperatur, Humidity, Lightlevel,... // Sensor PINS #define SENSOR1_PIN A3 // AnalogTemp on A3 #define SENSOR2_PIN 6 // Digi #define SENSOR3_PIN A0 // LightLevel Sensor /* #define SENSOR4_PIN 3 #define SENSOR5_PIN 3 #define SENSOR6_PIN 3 #define SENSOR7_PIN 3 #define SENSOR8_PIN 3 #define SENSOR9_PIN 3 */ // MyMessage V_TEMP, V_LIGHT_LEVEL, ... depending on Sensor Type MyMessage msg11(SENSOR1_ID,V_TEMP); MyMessage msg12(SENSOR2_ID,V_TEMP); MyMessage msg13(SENSOR3_ID,V_LIGHT_LEVEL); /* MyMessage msg14(SENSOR4_ID,V_TEMP); MyMessage msg15(SENSOR5_ID,V_TEMP); MyMessage msg16(SENSOR6_ID,V_TEMP); MyMessage msg17(SENSOR7_ID,V_TEMP); MyMessage msg18(SENSOR8_ID,V_TEMP); MyMessage msg19(SENSOR9_ID,V_TEMP); */ // Interval for each Sensor Read (number of loops) 1000000 = ca. 60 Sec - Adruino Nano ATmega 328 long int sensorInterval1 = 100000; long int sensorInterval2 = 100000; long int sensorInterval3 = 100000; /* long int sensorInterval4 = 1000000; long int sensorInterval5 = 1000000; long int sensorInterval6 = 1000000; long int sensorInterval7 = 1000000; long int sensorInterval8 = 1000000; long int sensorInterval9 = 1000000; */ // Special Config for each Sensor // SENSOR 1 // SENSOR 2 // Dallas Temp Sensor #include <OneWire.h> #include <DallasTemperature.h> OneWire oneWire(SENSOR2_PIN); DallasTemperature sensors(&oneWire); boolean receivedConfig = false; boolean metric = true; // SENSOR 3 // SENSOR 4 // SENSOR 5 // SENSOR 6 // SENSOR 7 // SENSOR 8 // SENSOR 9 //for sending only if value changed float lastRead1; float lastRead2; float lastRead3; float lastRead4; float lastRead5; float lastRead6; float lastRead7; float lastRead8; float lastRead9; //for loops long int sI1 = sensorInterval1; long int sI2 = sensorInterval2; long int sI3 = sensorInterval3; /* long int sI4 = sensorInterval4; long int sI5 = sensorInterval5; long int sI6 = sensorInterval6; long int sI7 = sensorInterval7; long int sI8 = sensorInterval8; long int sI9 = sensorInterval9; */ //----------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------- // VOID SETUP - VOID SETUP - VOID SETUP - VOID SETUP - VOID SETUP //----------------------------------------------------------------------------------------------------------- void setup() { gw.begin(incomingMessage, AUTO, true); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("3But.2Led.1DigTemp.1LightSens", "1.4.1"); //------------------------------------------------------------------------ // Triggers - Triggers - Triggers - Triggers - Triggers - Triggers //------------------------------------------------------------------------ // VOID SETUP pinMode(TRIGGER1_PIN,INPUT); pinMode(TRIGGER2_PIN,INPUT); pinMode(TRIGGER3_PIN,INPUT); /* pinMode(TRIGGER4_PIN,INPUT); pinMode(TRIGGER5_PIN,INPUT); pinMode(TRIGGER6_PIN,INPUT); pinMode(TRIGGER7_PIN,INPUT); pinMode(TRIGGER8_PIN,INPUT); pinMode(TRIGGER9_PIN,INPUT); */ // Activate internal pull-up digitalWrite(TRIGGER1_PIN,HIGH); digitalWrite(TRIGGER2_PIN,HIGH); digitalWrite(TRIGGER3_PIN,HIGH); /* digitalWrite(TRIGGER4_PIN,HIGH); digitalWrite(TRIGGER5_PIN,HIGH); digitalWrite(TRIGGER6_PIN,HIGH); digitalWrite(TRIGGER7_PIN,HIGH); digitalWrite(TRIGGER8_PIN,HIGH); digitalWrite(TRIGGER9_PIN,HIGH); */ // After setting up the button, setup debouncer debouncer1.attach(TRIGGER1_PIN); debouncer2.attach(TRIGGER2_PIN); debouncer3.attach(TRIGGER3_PIN); /* debouncer4.attach(TRIGGER4_PIN); debouncer5.attach(TRIGGER5_PIN); debouncer6.attach(TRIGGER6_PIN); debouncer7.attach(TRIGGER7_PIN); debouncer8.attach(TRIGGER8_PIN); debouncer9.attach(TRIGGER9_PIN); */ debouncer1.interval(5); debouncer2.interval(5); debouncer3.interval(5); /* debouncer4.interval(5); debouncer5.interval(5); debouncer6.interval(5); debouncer7.interval(5); debouncer8.interval(5); debouncer9.interval(5); */ // present all Triggers to Gateway gw.present(TRIGGER1_ID, S_DOOR); gw.present(TRIGGER2_ID, S_DOOR); gw.present(TRIGGER3_ID, S_DOOR); /* gw.present(TRIGGER4_ID, S_DOOR); gw.present(TRIGGER5_ID, S_DOOR); gw.present(TRIGGER6_ID, S_DOOR); gw.present(TRIGGER7_ID, S_DOOR); gw.present(TRIGGER8_ID, S_DOOR); gw.present(TRIGGER9_ID, S_DOOR); */ //------------------------------------------------------------------------ // Actuators - Actuators - Actuators - Actuators - Actuators - Actuators //------------------------------------------------------------------------ // VOID SETUP pinMode(ACTUATOR1_PIN, OUTPUT); pinMode(ACTUATOR2_PIN, OUTPUT); pinMode(ACTUATOR3_PIN, OUTPUT); /* pinMode(ACTUATOR4_PIN, OUTPUT); pinMode(ACTUATOR5_PIN, OUTPUT); pinMode(ACTUATOR6_PIN, OUTPUT); pinMode(ACTUATOR7_PIN, OUTPUT); pinMode(ACTUATOR8_PIN, OUTPUT); pinMode(ACTUATOR9_PIN, OUTPUT); */ // present all Actuators to Gateway gw.present(ACTUATOR1_ID, S_LIGHT); gw.present(ACTUATOR2_ID, S_LIGHT); gw.present(ACTUATOR3_ID, S_LIGHT); /* gw.present(ACTUATOR4_ID, S_LIGHT); gw.present(ACTUATOR5_ID, S_LIGHT); gw.present(ACTUATOR6_ID, S_LIGHT); gw.present(ACTUATOR7_ID, S_LIGHT); gw.present(ACTUATOR8_ID, S_LIGHT); gw.present(ACTUATOR9_ID, S_LIGHT); */ // FETCH old State and SET old state bool state1 = gw.loadState(ACTUATOR1_ID); digitalWrite(ACTUATOR1_ID, state1?ACTUATOR_ON:ACTUATOR_OFF); bool state2 = gw.loadState(ACTUATOR2_ID); digitalWrite(ACTUATOR2_ID, state2?ACTUATOR_ON:ACTUATOR_OFF); bool state3 = gw.loadState(ACTUATOR3_ID); digitalWrite(ACTUATOR3_ID, state3?ACTUATOR_ON:ACTUATOR_OFF); /* bool state4 = gw.loadState(ACTUATOR4_ID); digitalWrite(ACTUATOR4_ID, state4?ACTUATOR_ON:ACTUATOR_OFF); bool state5 = gw.loadState(ACTUATOR5_ID); digitalWrite(ACTUATOR5_ID, state5?ACTUATOR_ON:ACTUATOR_OFF); bool state6 = gw.loadState(ACTUATOR6_ID); digitalWrite(ACTUATOR6_ID, state6?ACTUATOR_ON:ACTUATOR_OFF); bool state7 = gw.loadState(ACTUATOR7_ID); digitalWrite(ACTUATOR7_ID, state7?ACTUATOR_ON:ACTUATOR_OFF); bool state8 = gw.loadState(ACTUATOR8_ID); digitalWrite(ACTUATOR8_ID, state8?ACTUATOR_ON:ACTUATOR_OFF); bool state9 = gw.loadState(ACTUATOR9_ID); digitalWrite(ACTUATOR9_ID, state9?ACTUATOR_ON:ACTUATOR_OFF); */ //------------------------------------------------------------------------ // Sensors - Sensors - Sensors - Sensors - Sensors - Sensors - Sensors //------------------------------------------------------------------------ // VOID SETUP // present all Sensors to Gateway - S_TEMP, S_LIGHT_LEVEL,... depending an SENSOR type gw.present(SENSOR1_ID, S_TEMP); gw.present(SENSOR2_ID, S_TEMP); gw.present(SENSOR3_ID, S_LIGHT_LEVEL); /* gw.present(SENSOR4_ID, S_TEMP); gw.present(SENSOR5_ID, S_TEMP); gw.present(SENSOR6_ID, S_TEMP); gw.present(SENSOR7_ID, S_TEMP); gw.present(SENSOR8_ID, S_TEMP); gw.present(SENSOR9_ID, S_TEMP); */ // Special SETUP for each Sensor // SENSOR 1 // SENSOR 2 - Dallas Temp Sensor sensors.begin(); // SENSOR 3 // SENSOR 4 // SENSOR 5 // SENSOR 6 // SENSOR 7 // SENSOR 8 // SENSOR 9 } //----------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------- // VOID LOOP - VOID LOOP - VOID LOOP - VOID LOOP - VOID LOOP - VOID LOOP //----------------------------------------------------------------------------------------------------------- // Check if digital input has changed and send in new value void loop() { gw.process(); //------------------------------------------------------------------------ // Triggers - Triggers - Triggers - Triggers - Triggers - Triggers //------------------------------------------------------------------------ // LOOP debouncer1.update(); debouncer2.update(); debouncer3.update(); /* debouncer4.update(); debouncer5.update(); debouncer6.update(); debouncer7.update(); debouncer8.update(); debouncer9.update(); */ // Get the update value int value1 = debouncer1.read(); int value2 = debouncer2.read(); int value3 = debouncer3.read(); /* int value4 = debouncer4.read(); int value5 = debouncer5.read(); int value6 = debouncer6.read(); int value7 = debouncer7.read(); int value8 = debouncer8.read(); int value9 = debouncer9.read(); */ // Send in the new value - if value changed if (value1 != oldTrigValue1) { gw.send(msg01.set(value1==LOW ? 1 : 0)); oldTrigValue1 = value1; } if (value2 != oldTrigValue2) { gw.send(msg02.set(value2==LOW ? 1 : 0)); oldTrigValue2 = value2; } if (value3 != oldTrigValue3) { gw.send(msg03.set(value3==LOW ? 1 : 0)); oldTrigValue3 = value3; } /* if (value4 != oldTrigValue4) { gw.send(msg04.set(value4==LOW ? 1 : 0)); oldTrigValue4 = value4; } if (value5 != oldTrigValue5) { gw.send(msg05.set(value5==LOW ? 1 : 0)); oldTrigValue5 = value5; } if (value6 != oldTrigValue6) { gw.send(msg06.set(value6==LOW ? 1 : 0)); oldTrigValue6 = value6; } if (value7 != oldTrigValue7) { gw.send(msg07.set(value7==LOW ? 1 : 0)); oldTrigValue7 = value7; } if (value8 != oldTrigValue8) { gw.send(msg08.set(value8==LOW ? 1 : 0)); oldTrigValue8 = value8; } if (value9 != oldTrigValue9) { gw.send(msg09.set(value9==LOW ? 1 : 0)); oldTrigValue9 = value9; } */ //------------------------------------------------------------------------ // Sensors - Sensors - Sensors - Sensors - Sensors - Sensors - Sensors //------------------------------------------------------------------------ // LOOP // Sensor1 - Analog Temp if (sI1 == sensorInterval1){ sI1 = 0; int sensorRead1 = analogRead(SENSOR1_PIN); if (lastRead1 != sensorRead1){ float sensorCalc = (sensorRead1 / 10) - 45.5; gw.send(msg11.set(sensorCalc,1)); lastRead1 = sensorRead1; } } // Sensor2 - Digital Temp Dallas if (sI2 == sensorInterval2){ sI2 = 0; sensors.requestTemperatures(); float sensorRead2 = static_cast<float>(static_cast<int>((gw.getConfig().isMetric?sensors.getTempCByIndex(0):sensors.getTempFByIndex(0)) * 10.)) / 10.; if (lastRead2 != sensorRead2){ gw.send(msg12.set(sensorRead2,1)); lastRead2 = sensorRead2; } } // Sensor3 - Light Level if (sI3 == sensorInterval3){ sI3 = 0; int sensorRead3 = analogRead(SENSOR3_PIN); if (lastRead3 != sensorRead3){ gw.send(msg13.set(sensorRead3,1)); lastRead3 = sensorRead3; } } /* // Sensor4 if (sI4 == sensorInterval4){ sI4 = 0; // put here the read sensor function like: // float sensorRead4 = analogRead(SENSOR4_PIN); if (lastRead4 != sensorRead4){ gw.send(msg14.set(sensorRead4)); lastRead4 = sensorRead4; } } // Sensor5 // Sensor6 // Sensor7 // Sensor8 // Sensor9 */ sI1++; sI2++; sI3++; /* sI4++; sI5++; sI6++; sI7++; sI8++; sI9++; */ } //------------------------------------------------------------------------ //------------------------------------------------------------------------ //------------------------------------------------------------------------ // VOID INCOMING MESSAGE - VOID INCOMING MESSAGE - VOID INCOMING MESSAGE //------------------------------------------------------------------------ void incomingMessage(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.isAck()) { Serial.println("This is an ack from gateway"); } //------------------------------------------------------------------------ // Actuators - Actuators - Actuators - Actuators - Actuators - Actuators //------------------------------------------------------------------------ // VOID INCOMING MESSAGE if (message.type==V_LIGHT) { int actPin; if (message.sensor == 11){ actPin = ACTUATOR1_PIN; } if (message.sensor == 12){ actPin = ACTUATOR2_PIN; } if (message.sensor == 13){ actPin = ACTUATOR3_PIN; } /* if (message.sensor == 14){ actPin = ACTUATOR4_PIN; } if (message.sensor == 15){ actPin = ACTUATOR5_PIN; } if (message.sensor == 16){ actPin = ACTUATOR6_PIN; } if (message.sensor == 17){ actPin = ACTUATOR7_PIN; } if (message.sensor == 18){ actPin = ACTUATOR8_PIN; } if (message.sensor == 19){ actPin = ACTUATOR9_PIN; } */ //------------------------------------------------------------------------ // switch Actuator normally //------------------------------------------------------------------------ if (message.getInt() < 2) { state = message.getBool(); digitalWrite(actPin, state?ACTUATOR_ON:ACTUATOR_OFF); gw.saveState(message.sensor, state); //Serial.print("normal Change for Actor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } //------------------------------------------------------------------------ // switch Actuator predifined //------------------------------------------------------------------------ if (message.getInt() == 2){ // BLINK 1x digitalWrite(actPin, LOW); delay(2000); digitalWrite(actPin, HIGH); delay(500); digitalWrite(actPin, LOW); delay(2000); // set state back to old state gw.loadState(message.sensor); digitalWrite(actPin, state?ACTUATOR_ON:ACTUATOR_OFF); MyMessage msgTmp(message.sensor,V_LIGHT); gw.send(msgTmp.set(state)); } if (message.getInt() == 3){ // BLINK 2x digitalWrite(actPin, LOW); delay(2000); digitalWrite(actPin, HIGH); delay(500); digitalWrite(actPin, LOW); delay(500); digitalWrite(actPin, HIGH); delay(500); digitalWrite(actPin, LOW); delay(2000); // set state back to old state gw.loadState(message.sensor); digitalWrite(actPin, state?ACTUATOR_ON:ACTUATOR_OFF); MyMessage msgTmp(message.sensor,V_LIGHT); gw.send(msgTmp.set(state)); } } }
Within FHEM Controller:
The FHEM.cfg Code:
And some example of my FHEM.cfg, how to use it:
#------------------------------------------------------#
# Testboard #
#------------------------------------------------------#
define Testboard MYSENSORS_DEVICE 100
attr Testboard IODev gateway
attr Testboard mapReading_brightness23 23 brightness
attr Testboard mapReading_switch11 11 switch
attr Testboard mapReading_switch12 12 switch
attr Testboard mapReading_switch13 13 switch
attr Testboard mapReading_temperature21 21 temperature
attr Testboard mapReading_temperature22 22 temperature
attr Testboard mapReading_tripped1 1 tripped
attr Testboard mapReading_tripped2 2 tripped
attr Testboard mapReading_tripped3 3 tripped
attr Testboard mode repeater
attr Testboard room MySensorsTB
attr Testboard setCommands on1:switch11:on off1:switch11:off on2:switch12:on off2:switch12:off on3:switch13:on off3:switch13:off ack11:switch11:2 ack12:switch11:3 ack21:switch12:2 ack22:switch12:3 ack31:switch13:2 ack32:switch13:3
attr Testboard setReading_switch11 on,off
attr Testboard setReading_switch12 on,off
attr Testboard setReading_switch13 on,off
attr Testboard version 1.4.1#------------------------------------------------------# # Actuators # #------------------------------------------------------# # Orange LED define OrangeLED dummy attr OrangeLED group Schalter attr OrangeLED room MySensorsTB attr OrangeLED setList on off 2 3 attr OrangeLED webCmd on:off:2:3 # normal Switch on define OrangeLED1 notify OrangeLED:on set Testboard on1 define OrangeLED0 notify OrangeLED:off set Testboard off1 # predefined Switching define OrangeLEDack1 notify OrangeLED:2 set Testboard ack11 define OrangeLEDack2 notify OrangeLED:3 set Testboard ack12 # Red LED define RedLED dummy attr RedLED group Schalter attr RedLED room MySensorsTB attr RedLED setList on off 2 3 attr RedLED webCmd on:off:2:3 # normal Switch on define RedLED1 notify RedLED:on set Testboard on2 define RedLED2 notify RedLED:off set Testboard off2 # predefined Switching define RedLEDack1 notify RedLED:2 set Testboard ack21 define RedLEDack2 notify RedLED:3 set Testboard ack22 # PIEZO define PIEZO dummy attr PIEZO group Schalter attr PIEZO room MySensorsTB attr PIEZO setList on off 2 3 attr PIEZO webCmd on:off:2:3 # normal Switch on define PIEZO1 notify PIEZO:on set Testboard on3 define PIEZO2 notify PIEZO:off set Testboard off3 # predefined Switching define PIEZOack1 notify PIEZO:2 set Testboard ack31 define PIEZOack2 notify PIEZO:3 set Testboard ack32 #------------------------------------------------------# # Sensordata # #------------------------------------------------------# # Analog Temperature Sensor define AnalogTemp dummy attr AnalogTemp event-on-change-reading state attr AnalogTemp room MySensorsTB attr AnalogTemp group Sensors # get all 30 Sec. Temp from Testboard define AnalogTempCopy at +*00:00:30 { my $d= ReadingsVal("Testboard","temperature21",0);; fhem("set AnalogTemp $d");;} # in eigene Log Datei schreiben define AnalogTempLog FileLog ./log/Log_AnalogTemp-%Y-%m-%d.log AnalogTemp attr AnalogTempLog group SensorLogs attr AnalogTempLog logtype text attr AnalogTempLog room MySensorsTB define DigiTemp dummy attr DigiTemp event-on-change-reading state attr DigiTemp room MySensorsTB attr DigiTemp group Sensors # get all 30 Sec. Temp from Testboard define DigiTempCopy at +*00:00:30 { my $d= ReadingsVal("Testboard","temperature22",0);; fhem("set DigiTemp $d");;} # in eigene Log Datei schreiben define DigiTempLog FileLog ./log/Log_DigiTemp-%Y-%m-%d.log DigiTemp attr DigiTempLog group SensorLogs attr DigiTempLog logtype text attr DigiTempLog room MySensorsTB define LightLevel dummy attr LightLevel event-on-change-reading state attr LightLevel room MySensorsTB attr LightLevel group Sensors # get all 30 Sec. Temp from Testboard define LightLevelCopy at +*00:00:30 { my $d= ReadingsVal("Testboard","brightness23",0);; fhem("set LightLevel $d");;} # in eigene Log Datei schreiben define LightLevelLog FileLog ./log/Log_LightLevel-%Y-%m-%d.log LightLevel attr LightLevelLog group SensorLogs attr LightLevelLog logtype text attr LightLevelLog room MySensorsTB
-
Thanks for sharing your project, very nicely documented. I don't have a real use for it at the moment but enjoyed very much to read a complete solution beginning with hardware and ending with FHEM.cfg code. Good Work!
Best regards
Dirk H
-
Dummy device status doesnt change when I press the button, how to set the dummy state on reading change? I don't know so much about fhem config file
-
Question :
For the dallas sensor , if I add more sensors can I add them to the same pin (D6) or it needs a different pin ?
-
@oscarc
hope this will answer your question:
or this:
-
@marekd Thank you, it does help :
Suggested Topics
-
Welcome
Announcements • • hek