Refactor LightNode::level() and fix compiler warning
@@ -218,29 +218,14 @@ bool LightNode::hasColor() const
*/
uint16_t LightNode::level() const
{
- switch (m_haEndpoint.deviceId())
- {
- case DEV_ID_MAINS_POWER_OUTLET:
- case DEV_ID_HA_ONOFF_LIGHT:
-//#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
- if (m_haEndpoint.profileId() == ZLL_PROFILE_ID)
- {
- // don't clash with DEV_ID_ZLL_DIMMABLE_LIGHT
- break;
- }
- case DEV_ID_ZLL_ONOFF_LIGHT:
- case DEV_ID_ZLL_ONOFF_PLUGIN_UNIT:
- case DEV_ID_Z30_ONOFF_PLUGIN_UNIT:
+ const ResourceItem *it = item(RStateBri);
+
+ if (!it)
{
- const ResourceItem *it = item(RStateOn);
+ it = item(RStateOn);
return (it && it->toBool() ? 254 : 0);
}
- default:
- break;
- }
-
- const ResourceItem *it = item(RStateBri);
return it ? it->toNumber() : 0;
}
