Add helpers for mandatory attributes in AnalogInput cluster

pull/38/head
Michael Zanetti 2022-01-30 22:04:53 +01:00
parent 977e31f2ba
commit 7ccbfc3a6d
2 changed files with 31 additions and 0 deletions

View File

@ -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>(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;
}
}

View File

@ -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