diff --git a/libnymea-zigbee/zcl/general/zigbeeclusteranaloginput.cpp b/libnymea-zigbee/zcl/general/zigbeeclusteranaloginput.cpp index d1a0346..c1a4f50 100644 --- a/libnymea-zigbee/zcl/general/zigbeeclusteranaloginput.cpp +++ b/libnymea-zigbee/zcl/general/zigbeeclusteranaloginput.cpp @@ -34,8 +34,30 @@ ZigbeeClusterAnalogInput::ZigbeeClusterAnalogInput(ZigbeeNetwork *network, Zigbe } +bool ZigbeeClusterAnalogInput::outOfService() const +{ + return m_outOfService; +} + +float ZigbeeClusterAnalogInput::presentValue() const +{ + return m_presentValue; +} + void ZigbeeClusterAnalogInput::setAttribute(const ZigbeeClusterAttribute &attribute) { qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast(attribute.id()) << attribute.dataType(); updateOrAddAttribute(attribute); + + switch (attribute.id()) { + case AttributeOutOfService: + m_outOfService = attribute.dataType().toBool(); + emit outOfServiceChanged(m_outOfService); + break; + case AttributePresentValue: + m_presentValue = attribute.dataType().toFloat(); + qCDebug(dcZigbeeCluster()) << "Present value changed:" << m_presentValue; + emit presentValueChanged(m_presentValue); + break; + } } diff --git a/libnymea-zigbee/zcl/general/zigbeeclusteranaloginput.h b/libnymea-zigbee/zcl/general/zigbeeclusteranaloginput.h index 402d11f..7579f90 100644 --- a/libnymea-zigbee/zcl/general/zigbeeclusteranaloginput.h +++ b/libnymea-zigbee/zcl/general/zigbeeclusteranaloginput.h @@ -56,9 +56,18 @@ public: explicit ZigbeeClusterAnalogInput(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr); + bool outOfService() const; + float presentValue() const; + +signals: + void outOfServiceChanged(bool outOfService); + void presentValueChanged(float presentValue); + private: void setAttribute(const ZigbeeClusterAttribute &attribute) override; + bool m_outOfService = false; + float m_presentValue = 0; }; #endif // ZIGBEECLUSTERANALOGINPUT_H