diff --git a/content/entities/light/light.tscn b/content/entities/light/light.tscn index 4602274..dc72388 100644 --- a/content/entities/light/light.tscn +++ b/content/entities/light/light.tscn @@ -3,7 +3,7 @@ [ext_resource type="Script" path="res://content/entities/light/light.gd" id="1_ykxy3"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="4_4sfxb"] [ext_resource type="Material" uid="uid://vce66e7sbc3n" path="res://content/entities/light/light_on.tres" id="5_50gph"] -[ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="6_mhjlm"] +[ext_resource type="PackedScene" path="res://content/ui/components/slider/slider.tscn" id="6_mhjlm"] [sub_resource type="SphereShape3D" id="SphereShape3D_ukj14"] radius = 0.05 diff --git a/content/entities/media_player/media_player.gd b/content/entities/media_player/media_player.gd index 26ef9f2..1618340 100644 --- a/content/entities/media_player/media_player.gd +++ b/content/entities/media_player/media_player.gd @@ -10,8 +10,11 @@ extends StaticBody3D @onready var title = $PlayingInfo/Title @onready var artist = $PlayingInfo/Artist @onready var http_request = $PlayingInfo/HTTPRequest +@onready var slider = $Slider var playing = false +var volume = 50 + # Called when the node enters the scene tree for the first time. func _ready(): @@ -37,18 +40,25 @@ func _ready(): HomeApi.set_state(entity_id, "next") ) + slider.on_value_changed.connect(set_volume) + + +func set_volume(value): + volume = value + HomeApi.set_state(entity_id, "volume", {"volume_level": value / 100}) func set_state(stateInfo): var state = stateInfo["state"] - print("State changed to ", stateInfo) - if state == "playing": if stateInfo["attributes"].has("entity_picture_local"): load_image(stateInfo["attributes"]["entity_picture_local"]) title.text = stateInfo["attributes"]["media_title"] artist.text = stateInfo["attributes"]["media_artist"] + volume = float(stateInfo["attributes"]["volume_level"]) * 100 + slider.value = volume + playing = true play.label = "pause" else: diff --git a/content/entities/media_player/media_player.tscn b/content/entities/media_player/media_player.tscn index b9ee985..c721f57 100644 --- a/content/entities/media_player/media_player.tscn +++ b/content/entities/media_player/media_player.tscn @@ -1,8 +1,10 @@ -[gd_scene load_steps=5 format=3 uid="uid://dyktdg7ggiwl4"] +[gd_scene load_steps=7 format=3 uid="uid://dyktdg7ggiwl4"] [ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="1_8opk3"] [ext_resource type="Script" path="res://content/entities/media_player/media_player.gd" id="1_ame17"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="3_bguto"] +[ext_resource type="PackedScene" path="res://content/ui/components/slider/slider.tscn" id="4_w73hw"] +[ext_resource type="FontVariation" uid="uid://sshfnckriqxn" path="res://assets/icons/icons.tres" id="5_koe28"] [sub_resource type="BoxShape3D" id="BoxShape3D_vi3eg"] size = Vector3(0.23, 0.142768, 0.01) @@ -56,3 +58,20 @@ pixel_size = 0.001 [node name="Movable" type="Node" parent="."] script = ExtResource("3_bguto") + +[node name="Slider" parent="." instance=ExtResource("4_w73hw")] +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.0562844, 0) +max = 100.0 +value = 30.0 +step = 1.0 +show_label = true +label_unit = "%" +size = Vector3(15, 0.4, 1) + +[node name="Label3D" type="Label3D" parent="Slider"] +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.088399, 0, 0) +pixel_size = 0.001 +text = "volume_up" +font = ExtResource("5_koe28") +font_size = 18 +outline_size = 4 diff --git a/content/ui/menu/settings/settings_menu.tscn b/content/ui/menu/settings/settings_menu.tscn index e279d0a..642900f 100644 --- a/content/ui/menu/settings/settings_menu.tscn +++ b/content/ui/menu/settings/settings_menu.tscn @@ -58,7 +58,7 @@ horizontal_alignment = 0 [node name="InputURL" parent="Content" instance=ExtResource("4_q3x6k")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.18, 0, 0.03) -text = "ws://192.168.33.33:8123" +text = "ws://192.168.0.1:8123" [node name="LabelToken" type="Label3D" parent="Content"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.01, 0, 0.07) diff --git a/lib/home_apis/hass_ws/hass.gd b/lib/home_apis/hass_ws/hass.gd index 16cd3a1..29f847d 100644 --- a/lib/home_apis/hass_ws/hass.gd +++ b/lib/home_apis/hass_ws/hass.gd @@ -254,6 +254,8 @@ func set_state(entity: String, state: String, attributes: Dictionary = {}): service = "media_next_track" elif state == "previous": service = "media_previous_track" + elif state == "volume": + service = "volume_set" if service == null: return null