forked from platypush/platypush
Added is_query_disabled attribute to entities
This commit is contained in:
parent
84bb77bd5b
commit
02a4c9f667
2 changed files with 22 additions and 14 deletions
|
@ -42,6 +42,7 @@ class Entity(Base):
|
||||||
meta = Column(JSON, default=dict)
|
meta = Column(JSON, default=dict)
|
||||||
is_read_only = Column(Boolean, default=False)
|
is_read_only = Column(Boolean, default=False)
|
||||||
is_write_only = Column(Boolean, default=False)
|
is_write_only = Column(Boolean, default=False)
|
||||||
|
is_query_disabled = Column(Boolean, default=False)
|
||||||
created_at = Column(
|
created_at = Column(
|
||||||
DateTime(timezone=False), default=datetime.utcnow(), nullable=False
|
DateTime(timezone=False), default=datetime.utcnow(), nullable=False
|
||||||
)
|
)
|
||||||
|
|
|
@ -257,6 +257,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
data=dev_info,
|
data=dev_info,
|
||||||
is_read_only=switch_info['is_read_only'],
|
is_read_only=switch_info['is_read_only'],
|
||||||
is_write_only=switch_info['is_write_only'],
|
is_write_only=switch_info['is_write_only'],
|
||||||
|
is_query_disabled=switch_info['is_query_disabled'],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1477,6 +1478,10 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
or bool(feature.get('access', 0) & 4) == 0
|
or bool(feature.get('access', 0) & 4) == 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _is_query_disabled(feature: dict) -> bool:
|
||||||
|
return bool(feature.get('access', 0) & 4) == 0
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _ieee_address(
|
def _ieee_address(
|
||||||
device: Union[dict, str], with_property=False
|
device: Union[dict, str], with_property=False
|
||||||
|
@ -1520,6 +1525,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
'value_toggle': feature.get('value_toggle', None),
|
'value_toggle': feature.get('value_toggle', None),
|
||||||
'is_read_only': cls._is_read_only(feature),
|
'is_read_only': cls._is_read_only(feature),
|
||||||
'is_write_only': cls._is_write_only(feature),
|
'is_write_only': cls._is_write_only(feature),
|
||||||
|
'is_query_disabled': cls._is_query_disabled(feature),
|
||||||
}
|
}
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
@ -1547,6 +1553,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
'description': exposed.get('description'),
|
'description': exposed.get('description'),
|
||||||
'is_read_only': cls._is_read_only(exposed),
|
'is_read_only': cls._is_read_only(exposed),
|
||||||
'is_write_only': cls._is_write_only(exposed),
|
'is_write_only': cls._is_write_only(exposed),
|
||||||
|
'is_query_disabled': cls._is_query_disabled(exposed),
|
||||||
'data': device_info,
|
'data': device_info,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1617,6 +1624,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
description=exposed.get('description'),
|
description=exposed.get('description'),
|
||||||
is_read_only=cls._is_read_only(exposed),
|
is_read_only=cls._is_read_only(exposed),
|
||||||
is_write_only=cls._is_write_only(exposed),
|
is_write_only=cls._is_write_only(exposed),
|
||||||
|
is_query_disabled=cls._is_query_disabled(exposed),
|
||||||
data=device_info,
|
data=device_info,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -1635,6 +1643,12 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
color = {}
|
color = {}
|
||||||
|
|
||||||
for feature in features:
|
for feature in features:
|
||||||
|
data = {
|
||||||
|
'is_read_only': cls._is_read_only(feature),
|
||||||
|
'is_write_only': cls._is_write_only(feature),
|
||||||
|
'is_query_disabled': cls._is_query_disabled(feature),
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
feature.get('property') == 'state'
|
feature.get('property') == 'state'
|
||||||
and feature.get('type') == 'binary'
|
and feature.get('type') == 'binary'
|
||||||
|
@ -1646,8 +1660,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
'value_off': feature['value_off'],
|
'value_off': feature['value_off'],
|
||||||
'state_name': feature['name'],
|
'state_name': feature['name'],
|
||||||
'value_toggle': feature.get('value_toggle', None),
|
'value_toggle': feature.get('value_toggle', None),
|
||||||
'is_read_only': cls._is_read_only(feature),
|
**data,
|
||||||
'is_write_only': cls._is_write_only(feature),
|
|
||||||
}
|
}
|
||||||
elif (
|
elif (
|
||||||
feature.get('property') == 'brightness'
|
feature.get('property') == 'brightness'
|
||||||
|
@ -1659,8 +1672,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
'brightness_name': feature['name'],
|
'brightness_name': feature['name'],
|
||||||
'brightness_min': feature['value_min'],
|
'brightness_min': feature['value_min'],
|
||||||
'brightness_max': feature['value_max'],
|
'brightness_max': feature['value_max'],
|
||||||
'is_read_only': cls._is_read_only(feature),
|
**data,
|
||||||
'is_write_only': cls._is_write_only(feature),
|
|
||||||
}
|
}
|
||||||
elif (
|
elif (
|
||||||
feature.get('property') == 'color_temp'
|
feature.get('property') == 'color_temp'
|
||||||
|
@ -1672,8 +1684,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
'temperature_name': feature['name'],
|
'temperature_name': feature['name'],
|
||||||
'temperature_min': feature['value_min'],
|
'temperature_min': feature['value_min'],
|
||||||
'temperature_max': feature['value_max'],
|
'temperature_max': feature['value_max'],
|
||||||
'is_read_only': cls._is_read_only(feature),
|
**data,
|
||||||
'is_write_only': cls._is_write_only(feature),
|
|
||||||
}
|
}
|
||||||
elif (
|
elif (
|
||||||
feature.get('property') == 'color'
|
feature.get('property') == 'color'
|
||||||
|
@ -1689,8 +1700,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
'hue_max': color_feature.get(
|
'hue_max': color_feature.get(
|
||||||
'value_max', 65535
|
'value_max', 65535
|
||||||
),
|
),
|
||||||
'is_read_only': cls._is_read_only(feature),
|
**data,
|
||||||
'is_write_only': cls._is_write_only(feature),
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
elif color_feature.get('property') == 'saturation':
|
elif color_feature.get('property') == 'saturation':
|
||||||
|
@ -1703,8 +1713,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
'saturation_max': color_feature.get(
|
'saturation_max': color_feature.get(
|
||||||
'value_max', 255
|
'value_max', 255
|
||||||
),
|
),
|
||||||
'is_read_only': cls._is_read_only(feature),
|
**data,
|
||||||
'is_write_only': cls._is_write_only(feature),
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
elif color_feature.get('property') == 'x':
|
elif color_feature.get('property') == 'x':
|
||||||
|
@ -1713,8 +1722,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
'x_name': color_feature['name'],
|
'x_name': color_feature['name'],
|
||||||
'x_min': color_feature.get('value_min', 0.0),
|
'x_min': color_feature.get('value_min', 0.0),
|
||||||
'x_max': color_feature.get('value_max', 1.0),
|
'x_max': color_feature.get('value_max', 1.0),
|
||||||
'is_read_only': cls._is_read_only(feature),
|
**data,
|
||||||
'is_write_only': cls._is_write_only(feature),
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
elif color_feature.get('property') == 'y':
|
elif color_feature.get('property') == 'y':
|
||||||
|
@ -1723,8 +1731,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
'y_name': color_feature['name'],
|
'y_name': color_feature['name'],
|
||||||
'y_min': color_feature.get('value_min', 0),
|
'y_min': color_feature.get('value_min', 0),
|
||||||
'y_max': color_feature.get('value_max', 255),
|
'y_max': color_feature.get('value_max', 255),
|
||||||
'is_read_only': cls._is_read_only(feature),
|
**data,
|
||||||
'is_write_only': cls._is_write_only(feature),
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue