@@ -135,6 +135,15 @@ void C1Wire::SensorThread()
135
135
int pollPeriod = 300 * 1000 ;
136
136
m_sql.GetPreferencesVar (" 1WireSensorPollPeriod" , pollPeriod);
137
137
138
+ int pollIterations = 1 ;
139
+
140
+ if (pollPeriod > 1000 )
141
+ {
142
+ pollIterations = pollPeriod / 1000 ;
143
+ pollPeriod = 1000 ;
144
+ }
145
+
146
+ int iteration = 0 ;
138
147
139
148
while (!m_stoprequested)
140
149
{
@@ -148,13 +157,13 @@ void C1Wire::SensorThread()
148
157
PollSensors ();
149
158
}
150
159
}
151
- }
152
160
153
161
_log.Log (LOG_STATUS, " 1-Wire: Sensor thread terminating" );
162
+ }
154
163
155
164
void C1Wire::SwitchThread ()
156
165
{
157
- int pollPeriod = 300 * 1000 ;
166
+ int pollPeriod = 100 ;
158
167
m_sql.GetPreferencesVar (" 1WireSwitchPollPeriod" , pollPeriod);
159
168
160
169
// Rescan the bus once every 10 seconds if requested
@@ -535,6 +544,10 @@ void C1Wire::ReportTemperatureHumidity(const std::string& deviceId, const float
535
544
536
545
void C1Wire::ReportLightState (const std::string& deviceId, const int unit, const bool state)
537
546
{
547
+ #if defined(_DEBUG)
548
+ _log.Log (LOG_STATUS, " device '%s' unit %d state is %s" , deviceId.c_str (), unit, (state) ? " on" : " off" );
549
+ #endif
550
+
538
551
// check - is state changed ?
539
552
char num[16 ];
540
553
sprintf (num, " %s/%d" , deviceId.c_str (), unit);
@@ -544,11 +557,16 @@ void C1Wire::ReportLightState(const std::string& deviceId, const int unit, const
544
557
it = m_LastSwitchState.find (id);
545
558
if (it != m_LastSwitchState.end ())
546
559
{
547
- if (it-> second == state)
560
+ if (m_LastSwitchState[id] == state)
548
561
{
549
562
return ;
550
563
}
551
564
}
565
+
566
+ #if defined(_DEBUG)
567
+ _log.Log (LOG_STATUS, " device '%s' unit %d changed state to %s" , deviceId.c_str (), unit, (state) ? " on" : " off" );
568
+ #endif
569
+
552
570
m_LastSwitchState[id] = state;
553
571
554
572
unsigned char deviceIdByteArray[DEVICE_ID_SIZE]={0 };
0 commit comments