display correct names in entities menu
This commit is contained in:
parent
927521419f
commit
4c4b0fdd2a
|
@ -10,7 +10,7 @@
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_3qyo4"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_3qyo4"]
|
||||||
size = Vector3(0.32, 0.16, 0.02)
|
size = Vector3(0.32, 0.16, 0.02)
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_h0yvw"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_cw188"]
|
||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
render_priority = 10
|
render_priority = 10
|
||||||
shader = ExtResource("6_40cd1")
|
shader = ExtResource("6_40cd1")
|
||||||
|
@ -25,7 +25,7 @@ shader_parameter/corner_radius = 0.8
|
||||||
shader_parameter/roughness = 0.3
|
shader_parameter/roughness = 0.3
|
||||||
shader_parameter/grain_amount = 0.02
|
shader_parameter/grain_amount = 0.02
|
||||||
|
|
||||||
[sub_resource type="QuadMesh" id="QuadMesh_a23j8"]
|
[sub_resource type="QuadMesh" id="QuadMesh_ryeda"]
|
||||||
size = Vector2(0.32, 0.16)
|
size = Vector2(0.32, 0.16)
|
||||||
|
|
||||||
[node name="Timer" type="StaticBody3D" groups=["entity"]]
|
[node name="Timer" type="StaticBody3D" groups=["entity"]]
|
||||||
|
@ -78,7 +78,7 @@ label = "stop"
|
||||||
icon = true
|
icon = true
|
||||||
|
|
||||||
[node name="Panel" parent="." instance=ExtResource("5_j3gsb")]
|
[node name="Panel" parent="." instance=ExtResource("5_j3gsb")]
|
||||||
material_override = SubResource("ShaderMaterial_h0yvw")
|
material_override = SubResource("ShaderMaterial_cw188")
|
||||||
mesh = SubResource("QuadMesh_a23j8")
|
mesh = SubResource("QuadMesh_ryeda")
|
||||||
size = Vector2(0.32, 0.16)
|
size = Vector2(0.32, 0.16)
|
||||||
corner_radius = 0.8
|
corner_radius = 0.8
|
||||||
|
|
|
@ -18,8 +18,7 @@ func _ready():
|
||||||
|
|
||||||
if search.value != "":
|
if search.value != "":
|
||||||
return devices.filter(func(device):
|
return devices.filter(func(device):
|
||||||
var info=device.values()[0]
|
return device["name"].to_lower().find(search.value.to_lower()) != - 1||device["id"].to_lower().find(search.value.to_lower()) != - 1
|
||||||
return info["name"].to_lower().find(search.value.to_lower()) != - 1
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return devices
|
return devices
|
||||||
|
@ -47,13 +46,12 @@ func _ready():
|
||||||
child.free()
|
child.free()
|
||||||
|
|
||||||
for device in visible_devices.value:
|
for device in visible_devices.value:
|
||||||
var info=device.values()[0]
|
|
||||||
|
|
||||||
var button_instance=ButtonScene.instantiate()
|
var button_instance=ButtonScene.instantiate()
|
||||||
button_instance.label=info["name"]
|
button_instance.label=device["name"]
|
||||||
button_instance.font_size=8
|
button_instance.font_size=8
|
||||||
button_instance.on_button_up.connect(func():
|
button_instance.on_button_up.connect(func():
|
||||||
on_select_device.emit(device.keys()[0])
|
on_select_device.emit(device["id"])
|
||||||
)
|
)
|
||||||
grid_container.add_child(button_instance)
|
grid_container.add_child(button_instance)
|
||||||
|
|
||||||
|
|
|
@ -22,13 +22,13 @@ func _ready():
|
||||||
var entities=[]
|
var entities=[]
|
||||||
|
|
||||||
for device in devices:
|
for device in devices:
|
||||||
if device.keys()[0] == selected_device.value:
|
if device["id"] == selected_device.value:
|
||||||
entities=device.values()[0]["entities"]
|
entities=device["entities"]
|
||||||
break
|
break
|
||||||
|
|
||||||
if search.value != "":
|
if search.value != "":
|
||||||
return entities.filter(func(entity):
|
return entities.filter(func(entity):
|
||||||
return entity.to_lower().find(search.value.to_lower()) != - 1
|
return entity["name"].to_lower().find(search.value.to_lower()) != - 1||entity["id"].to_lower().find(search.value.to_lower()) != - 1
|
||||||
)
|
)
|
||||||
|
|
||||||
return entities
|
return entities
|
||||||
|
@ -61,10 +61,10 @@ func _ready():
|
||||||
|
|
||||||
for entity in visible_entities.value:
|
for entity in visible_entities.value:
|
||||||
var entity_node=EntityScene.instantiate()
|
var entity_node=EntityScene.instantiate()
|
||||||
entity_node.icon=EntityFactory.get_entity_icon(entity.split(".")[0])
|
entity_node.icon=EntityFactory.get_entity_icon(entity["id"].split(".")[0])
|
||||||
entity_node.text=entity
|
entity_node.text=entity["name"]
|
||||||
entity_node.on_select.connect(func():
|
entity_node.on_select.connect(func():
|
||||||
on_select_entity.emit(entity)
|
on_select_entity.emit(entity["id"])
|
||||||
)
|
)
|
||||||
entity_container.add_child(entity_node)
|
entity_container.add_child(entity_node)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
extends Node3D
|
extends Node3D
|
||||||
|
|
||||||
@onready var voice_assist = $Content/VoiceAssist
|
@onready var voice_assist = $VoiceAssist
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
var settings_store = Store.settings.state
|
var settings_store = Store.settings.state
|
||||||
|
|
|
@ -1,19 +1,23 @@
|
||||||
{% set devices = states | map(attribute='entity_id') | map('device_id') | unique | reject('eq',None) | list %}
|
{% set devices = states | map(attribute='entity_id') | map('device_id') | unique | reject('eq',None) | list %}
|
||||||
|
|
||||||
{%- set ns = namespace(devices = []) %}
|
{%- set ns = namespace(devices = [], entities = []) %}
|
||||||
{%- for device in devices %}
|
{%- for device in devices %}
|
||||||
{%- set entities = device_entities(device) | list %}
|
{%- set entities = device_entities(device) | list %}
|
||||||
|
{%- set ns.entities = [] %}
|
||||||
{%- if entities %}
|
{%- if entities %}
|
||||||
{%- set ns.devices = ns.devices + [ {device: {"name": device_attr(device, "name"), "entities": entities }} ] %}
|
{%- for entity in entities %}
|
||||||
|
{%- set ns.entities = ns.entities + [ {"id": entity, "name": state_attr(entity, "friendly_name")} ] %}
|
||||||
|
{%- endfor %}
|
||||||
|
{%- set ns.devices = ns.devices + [{"id": device, "name": device_attr(device, "name"), "entities": ns.entities } ] %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
{%- set ns_group = namespace(entities = []) %}
|
{%- set ns_group = namespace(entities = []) %}
|
||||||
{%- for state in states %}
|
{%- for state in states %}
|
||||||
{%- if device_id(state.entity_id) == None %}
|
{%- if device_id(state.entity_id) == None %}
|
||||||
{%- set ns_group.entities = ns_group.entities + [state.entity_id] %}
|
{%- set ns_group.entities = ns_group.entities + [{"id": state.entity_id, "name": state.entity_id}] %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
{%- set ns.devices = ns.devices + [ {"other": {"name": "Other", "entities": ns_group.entities }} ] %}
|
{%- set ns.devices = ns.devices + [ {"id": "other.other", "name": "Other", "entities": ns_group.entities } ] %}
|
||||||
|
|
||||||
{{ ns.devices }}
|
{{ ns.devices }}
|
|
@ -10,12 +10,19 @@ func _init():
|
||||||
var devices=await HomeApi.get_devices()
|
var devices=await HomeApi.get_devices()
|
||||||
|
|
||||||
devices.sort_custom(func(a, b):
|
devices.sort_custom(func(a, b):
|
||||||
return a.values()[0]["name"].to_lower() < b.values()[0]["name"].to_lower()
|
return a["name"].to_lower() < b["name"].to_lower()
|
||||||
)
|
)
|
||||||
|
|
||||||
for device in devices:
|
for device in devices:
|
||||||
device.values()[0]["entities"].sort_custom(func(a, b):
|
if device["name"] == null:
|
||||||
return a.to_lower() < b.to_lower()
|
device["name"]=device["id"]
|
||||||
|
|
||||||
|
for entity in device["entities"]:
|
||||||
|
if entity["name"] == null:
|
||||||
|
entity["name"]=entity["id"]
|
||||||
|
|
||||||
|
device["entities"].sort_custom(func(a, b):
|
||||||
|
return a["name"].to_lower() < b["name"].to_lower()
|
||||||
)
|
)
|
||||||
|
|
||||||
self.state.devices=devices
|
self.state.devices=devices
|
||||||
|
|
Loading…
Reference in New Issue
Block a user