forked from platypush/platypush
Added support for description/read_only/write_only on entity level
This commit is contained in:
parent
d261b9bb9b
commit
47f8520f3b
6 changed files with 11 additions and 5 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
<div class="col-2 switch pull-right">
|
||||
<ToggleSwitch :value="value.state" @input="toggle"
|
||||
@click.stop :disabled="loading" />
|
||||
@click.stop :disabled="loading || value.is_read_only" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -5,6 +5,7 @@ from typing import Mapping, Type, Tuple, Any
|
|||
|
||||
import pkgutil
|
||||
from sqlalchemy import (
|
||||
Boolean,
|
||||
Column,
|
||||
Index,
|
||||
Integer,
|
||||
|
@ -32,10 +33,13 @@ class Entity(Base):
|
|||
id = Column(Integer, autoincrement=True, primary_key=True)
|
||||
external_id = Column(String, nullable=True)
|
||||
name = Column(String, nullable=False, index=True)
|
||||
description = Column(String)
|
||||
type = Column(String, nullable=False, index=True)
|
||||
plugin = Column(String, nullable=False)
|
||||
data = Column(JSON, default=dict)
|
||||
meta = Column(JSON, default=dict)
|
||||
is_read_only = Column(Boolean, default=False)
|
||||
is_write_only = Column(Boolean, default=False)
|
||||
created_at = Column(
|
||||
DateTime(timezone=False), default=datetime.utcnow(), nullable=False
|
||||
)
|
||||
|
|
|
@ -114,6 +114,7 @@ class SwitchbotPlugin(SwitchPlugin):
|
|||
id=dev["id"],
|
||||
name=dev["name"],
|
||||
state=dev.get("on"),
|
||||
is_write_only=True,
|
||||
data={
|
||||
"device_type": dev.get("device_type"),
|
||||
"is_virtual": dev.get("is_virtual", False),
|
||||
|
|
|
@ -184,6 +184,7 @@ class SwitchbotBluetoothPlugin( # lgtm [py/missing-call-to-init]
|
|||
id=addr,
|
||||
name=name,
|
||||
state=False,
|
||||
is_write_only=True,
|
||||
)
|
||||
for addr, name in devices.items()
|
||||
]
|
||||
|
|
|
@ -178,7 +178,6 @@ class ZigbeeMqttPlugin(MqttPlugin, SwitchPlugin): # lgtm [py/missing-call-to-in
|
|||
"model": dev_def.get("model"),
|
||||
"vendor": dev_def.get("vendor"),
|
||||
"supported": dev.get("supported"),
|
||||
"description": dev_def.get("description"),
|
||||
}
|
||||
|
||||
switch_info = self._get_switch_meta(dev)
|
||||
|
@ -187,6 +186,7 @@ class ZigbeeMqttPlugin(MqttPlugin, SwitchPlugin): # lgtm [py/missing-call-to-in
|
|||
id=dev['ieee_address'],
|
||||
name=dev.get('friendly_name'),
|
||||
state=dev.get('state', {}).get('state') == 'ON',
|
||||
description=dev_def.get("description"),
|
||||
data=dev_info,
|
||||
)
|
||||
|
||||
|
|
|
@ -479,10 +479,10 @@ class ZwaveMqttPlugin(MqttPlugin, ZwaveBasePlugin):
|
|||
value_name=value["label"],
|
||||
),
|
||||
state=value['data'],
|
||||
description=value.get('help'),
|
||||
is_read_only=value.get('is_read_only'),
|
||||
is_write_only=value.get('is_write_only'),
|
||||
data={
|
||||
'help': value.get('help'),
|
||||
'is_read_only': value.get('is_read_only'),
|
||||
'is_write_only': value.get('is_write_only'),
|
||||
'label': value.get('label'),
|
||||
'node_id': value.get('node_id'),
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue