MCPcopy Create free account
hub / github.com/domoticz/domoticz / UpdateUserVariable

Method UpdateUserVariable

main/EventSystem.cpp:1383–1420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1381}
1382
1383void CEventSystem::UpdateUserVariable(const uint64_t ulDevID, const std::string& varname, const int eVartype, const std::string &varValue, const std::string &lastUpdate)
1384{
1385 if (!m_bEnabled)
1386 return;
1387
1388 boost::unique_lock<boost::shared_mutex> uservariablesMutexLock(m_uservariablesMutex);
1389
1390 auto itt = m_uservariables.find(ulDevID);
1391 if (itt == m_uservariables.end())
1392 {
1393 //not found, add it
1394 _tUserVariable uvitem;
1395 uvitem.ID = ulDevID;
1396 uvitem.variableName = varname;
1397 uvitem.variableValue = varValue;
1398 uvitem.variableType = eVartype;
1399 uvitem.lastUpdate = lastUpdate;
1400 m_uservariables[uvitem.ID] = uvitem;
1401
1402 itt = m_uservariables.find(ulDevID);
1403 }
1404
1405 _tUserVariable replaceitem = itt->second;
1406 replaceitem.variableValue = varValue;
1407
1408 if (GetEventTrigger(ulDevID, REASON_USERVARIABLE, false))
1409 {
1410 _tEventQueue item;
1411 item.reason = REASON_USERVARIABLE;
1412 item.id = ulDevID;
1413 item.sValue = varValue;
1414 item.lastUpdate = itt->second.lastUpdate;
1415 m_eventqueue.push(item);
1416 }
1417
1418 replaceitem.lastUpdate = lastUpdate;
1419 itt->second = replaceitem;
1420}
1421
1422void CEventSystem::UpdateBatteryLevel(const uint64_t ulDevID, const unsigned char batteryLevel)
1423{

Callers 2

parseBlocklyActionsMethod · 0.45
processLuaCommandMethod · 0.45

Calls 3

endMethod · 0.80
pushMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected