2023-10-31 23:15:33 +02:00
|
|
|
extends StaticBody3D
|
|
|
|
|
|
|
|
@export var entity_id = "switch.plug_printer_2"
|
|
|
|
@onready var sprite: AnimatedSprite3D = $Icon
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
2023-11-05 17:36:13 +02:00
|
|
|
var stateInfo = await HomeAdapters.adapter.get_state(entity_id)
|
2023-10-31 23:15:33 +02:00
|
|
|
if stateInfo["state"] == "on":
|
|
|
|
sprite.set_frame(0)
|
|
|
|
else:
|
|
|
|
sprite.set_frame(1)
|
|
|
|
|
|
|
|
|
|
|
|
func _on_toggle():
|
2023-11-05 17:36:13 +02:00
|
|
|
HomeAdapters.adapter.set_state(entity_id, "off" if sprite.get_frame() == 0 else "on")
|
2023-10-31 23:15:33 +02:00
|
|
|
if sprite.get_frame() == 0:
|
|
|
|
sprite.set_frame(1)
|
|
|
|
else:
|
|
|
|
sprite.set_frame(0)
|
|
|
|
|
|
|
|
func _on_request_completed():
|
|
|
|
pass
|