added connected state to all one wire devices
parent
a2bb2ccf10
commit
bb28d3417e
|
|
@ -312,23 +312,29 @@ void IntegrationPluginOneWire::onPluginTimer()
|
||||||
if (thing->thingClassId() == temperatureSensorThingClassId) {
|
if (thing->thingClassId() == temperatureSensorThingClassId) {
|
||||||
QByteArray address = thing->paramValue(temperatureSensorThingAddressParamTypeId).toByteArray();
|
QByteArray address = thing->paramValue(temperatureSensorThingAddressParamTypeId).toByteArray();
|
||||||
double temperature = 0;
|
double temperature = 0;
|
||||||
|
bool connected = false;
|
||||||
if (m_owfsInterface) {
|
if (m_owfsInterface) {
|
||||||
temperature = m_owfsInterface->getTemperature(address);
|
temperature = m_owfsInterface->getTemperature(address);
|
||||||
|
connected = m_owfsInterface->isConnected(address);
|
||||||
} else if (m_w1Interface) {
|
} else if (m_w1Interface) {
|
||||||
temperature = m_w1Interface->getTemperature(address);
|
temperature = m_w1Interface->getTemperature(address);
|
||||||
|
connected = m_w1Interface->deviceAvailable(address);
|
||||||
}
|
}
|
||||||
thing->setStateValue(temperatureSensorTemperatureStateTypeId, temperature);
|
thing->setStateValue(temperatureSensorTemperatureStateTypeId, temperature);
|
||||||
|
thing->setStateValue(temperatureSensorConnectedStateTypeId, connected);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thing->thingClassId() == singleChannelSwitchThingClassId) {
|
if (thing->thingClassId() == singleChannelSwitchThingClassId) {
|
||||||
QByteArray address = thing->paramValue(singleChannelSwitchThingAddressParamTypeId).toByteArray();
|
QByteArray address = thing->paramValue(singleChannelSwitchThingAddressParamTypeId).toByteArray();
|
||||||
thing->setStateValue(singleChannelSwitchDigitalOutputStateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_A));
|
thing->setStateValue(singleChannelSwitchDigitalOutputStateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_A));
|
||||||
|
thing->setStateValue(singleChannelSwitchConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thing->thingClassId() == dualChannelSwitchThingClassId) {
|
if (thing->thingClassId() == dualChannelSwitchThingClassId) {
|
||||||
QByteArray address = thing->paramValue(dualChannelSwitchThingAddressParamTypeId).toByteArray();
|
QByteArray address = thing->paramValue(dualChannelSwitchThingAddressParamTypeId).toByteArray();
|
||||||
thing->setStateValue(dualChannelSwitchDigitalOutput1StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_A));
|
thing->setStateValue(dualChannelSwitchDigitalOutput1StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_A));
|
||||||
thing->setStateValue(dualChannelSwitchDigitalOutput2StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_B));
|
thing->setStateValue(dualChannelSwitchDigitalOutput2StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_B));
|
||||||
|
thing->setStateValue(dualChannelSwitchConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thing->thingClassId() == eightChannelSwitchThingClassId) {
|
if (thing->thingClassId() == eightChannelSwitchThingClassId) {
|
||||||
|
|
@ -341,6 +347,7 @@ void IntegrationPluginOneWire::onPluginTimer()
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput6StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_F));
|
thing->setStateValue(eightChannelSwitchDigitalOutput6StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_F));
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput7StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_G));
|
thing->setStateValue(eightChannelSwitchDigitalOutput7StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_G));
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput8StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_H));
|
thing->setStateValue(eightChannelSwitchDigitalOutput8StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_H));
|
||||||
|
thing->setStateValue(eightChannelSwitchConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,14 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
|
{
|
||||||
|
"id": "32305a16-b042-4574-8bd7-ad99d9e8e5da",
|
||||||
|
"name": "connected",
|
||||||
|
"displayName": "connected",
|
||||||
|
"displayNameEvent": "connected changed",
|
||||||
|
"defaultValue": false,
|
||||||
|
"type": "bool"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "b04ee2a5-9b27-4ffc-9e12-7e05f5a41690",
|
"id": "b04ee2a5-9b27-4ffc-9e12-7e05f5a41690",
|
||||||
"name": "temperature",
|
"name": "temperature",
|
||||||
|
|
@ -102,7 +110,15 @@
|
||||||
"readOnly": true
|
"readOnly": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
|
{
|
||||||
|
"id": "16bae8e8-bfe1-4648-9018-f6ce610f4236",
|
||||||
|
"name": "connected",
|
||||||
|
"displayName": "connected",
|
||||||
|
"displayNameEvent": "connected changed",
|
||||||
|
"defaultValue": false,
|
||||||
|
"type": "bool"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "ca10a9fd-e4e0-4608-a2d2-6a4ce9644f40",
|
"id": "ca10a9fd-e4e0-4608-a2d2-6a4ce9644f40",
|
||||||
"name": "digitalOutput",
|
"name": "digitalOutput",
|
||||||
|
|
@ -139,6 +155,14 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
|
{
|
||||||
|
"id": "fb6e63db-316b-4959-a349-0ff58a679f71",
|
||||||
|
"name": "connected",
|
||||||
|
"displayName": "connected",
|
||||||
|
"displayNameEvent": "connected changed",
|
||||||
|
"defaultValue": false,
|
||||||
|
"type": "bool"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "f8b6b4a7-355c-4580-a676-8a4d0d619ff9",
|
"id": "f8b6b4a7-355c-4580-a676-8a4d0d619ff9",
|
||||||
"name": "digitalOutput1",
|
"name": "digitalOutput1",
|
||||||
|
|
@ -186,6 +210,14 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
|
{
|
||||||
|
"id": "b99585e0-5147-46e3-9474-fba555bac68a",
|
||||||
|
"name": "connected",
|
||||||
|
"displayName": "connected",
|
||||||
|
"displayNameEvent": "connected changed",
|
||||||
|
"defaultValue": false,
|
||||||
|
"type": "bool"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "78fa12c0-246c-4112-8be6-5943d3c3cda5",
|
"id": "78fa12c0-246c-4112-8be6-5943d3c3cda5",
|
||||||
"name": "digitalOutput1",
|
"name": "digitalOutput1",
|
||||||
|
|
|
||||||
|
|
@ -111,11 +111,16 @@ bool Owfs::discoverDevices()
|
||||||
bool Owfs::interfaceIsAvailable()
|
bool Owfs::interfaceIsAvailable()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
//TODO
|
||||||
|
//QByteArray fullPath;
|
||||||
|
//fullPath.append(m_path);
|
||||||
|
//if(OW_present(fullPath) < 0)
|
||||||
|
// return false;
|
||||||
|
//return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Owfs::isConnected(const QByteArray &address)
|
bool Owfs::isConnected(const QByteArray &address)
|
||||||
{
|
{
|
||||||
Q_UNUSED(address)
|
|
||||||
QByteArray fullPath;
|
QByteArray fullPath;
|
||||||
fullPath.append(m_path);
|
fullPath.append(m_path);
|
||||||
fullPath.append(address);
|
fullPath.append(address);
|
||||||
|
|
|
||||||
|
|
@ -66,12 +66,17 @@ bool W1::interfaceIsAvailable()
|
||||||
return w1SysFSDir.exists();
|
return w1SysFSDir.exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool W1::deviceAvailable(const QString &address)
|
||||||
|
{
|
||||||
|
QDir temperatureSensor("/sys/bus/w1/devices/"+address);
|
||||||
|
return temperatureSensor.exists();
|
||||||
|
}
|
||||||
|
|
||||||
double W1::getTemperature(const QString &address)
|
double W1::getTemperature(const QString &address)
|
||||||
{
|
{
|
||||||
QDir temperatureSensor("/sys/bus/w1/devices/"+address);
|
QDir temperatureSensor("/sys/bus/w1/devices/"+address);
|
||||||
if (temperatureSensor.exists()) {
|
if (temperatureSensor.exists()) {
|
||||||
qCDebug(dcOneWire()) << "Temperature" << address;
|
QFile temperature(temperatureSensor.path() +"/temperature");
|
||||||
QFile temperature(temperatureSensor.dirName()+"/temperature");
|
|
||||||
if (!temperature.exists()) {
|
if (!temperature.exists()) {
|
||||||
qCWarning(dcOneWire()) << "Directory doesn't exist" << temperature.fileName();
|
qCWarning(dcOneWire()) << "Directory doesn't exist" << temperature.fileName();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ public:
|
||||||
|
|
||||||
QStringList discoverDevices();
|
QStringList discoverDevices();
|
||||||
bool interfaceIsAvailable();
|
bool interfaceIsAvailable();
|
||||||
|
bool deviceAvailable(const QString &address);
|
||||||
double getTemperature(const QString &address);
|
double getTemperature(const QString &address);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue