@bartik22, wracając do tego twojego flow, możesz go zaimportować? Raczej z grafiki to go nie odtworzę, nie jestem taki biegły w tych klockach
Prosze bardzo
jak nie bedziesz rozumial jakiegos punktu, daj znać.
[{"id":"5798032a.fc88ac","type":"tab","label":"test","disabled":false,"info":""},{"id":"1d8d0d37.9b9403","type":"api-call-service","z":"5798032a.fc88ac","name":"Ustawienie głośności","server":"","version":1,"debugenabled":true,"service_domain":"media_player","service":"volume_set","entityId":"media_player.lazienka","data":"{\"volume_level\":\"0.5\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":330,"y":510,"wires":[["4f7d7e7a.e97f6"]]},{"id":"34f1138c.fdf04c","type":"delay","z":"5798032a.fc88ac","name":"100 milisekund","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":140,"y":510,"wires":[["1d8d0d37.9b9403"]]},{"id":"3c9b8a2c.9264b6","type":"api-call-service","z":"5798032a.fc88ac","name":"Głośnik STOP","server":"","version":1,"debugenabled":true,"service_domain":"media_player","service":"media_stop","entityId":"media_player.lazienka","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":990,"y":370,"wires":[["34f1138c.fdf04c"]]},{"id":"9c317b29.1b9be8","type":"change","z":"5798032a.fc88ac","name":"Zapisuję na boku 3","rules":[{"t":"set","p":"glosnosc","pt":"flow","to":"data.attributes.volume_level","tot":"msg"},{"t":"set","p":"playing","pt":"flow","to":"music","tot":"str"},{"t":"set","p":"stacja","pt":"flow","to":"data.attributes.media_content_id","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":370,"wires":[["3c9b8a2c.9264b6"]]},{"id":"c59974ca.a211f8","type":"change","z":"5798032a.fc88ac","name":"Zapisuję na boku 1","rules":[{"t":"set","p":"glosnosc","pt":"flow","to":"data.attributes.volume_level","tot":"msg"},{"t":"set","p":"playing","pt":"flow","to":"off","tot":"str"},{"t":"set","p":"stacja","pt":"flow","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":330,"wires":[["3c9b8a2c.9264b6"]]},{"id":"e51a7f79.7f9e7","type":"switch","z":"5798032a.fc88ac","name":"Gra?","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"playing","vt":"str"},{"t":"eq","v":"playing","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":640,"y":370,"wires":[["c59974ca.a211f8"],["9c317b29.1b9be8"]]},{"id":"a93c2f13.d52d8","type":"api-current-state","z":"5798032a.fc88ac","name":"Pobieram dane głośnika","server":"","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"media_player.lazienka","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":460,"y":370,"wires":[["e51a7f79.7f9e7"]]},{"id":"aa420fcd.1eb12","type":"api-call-service","z":"5798032a.fc88ac","name":"Ustawiam głośność","server":"","version":1,"debugenabled":true,"service_domain":"media_player","service":"volume_set","entityId":"media_player.lazienka","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1090,"y":660,"wires":[[]]},{"id":"bff67f79.50c5e","type":"function","z":"5798032a.fc88ac","name":"Ustawiam zapisaną głosność","func":"var glosnosc = flow.get(\"glosnosc\");\nmsg.payload =\n{\n \"data\":\n {\n \"volume_level\":glosnosc,\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":860,"y":660,"wires":[["aa420fcd.1eb12"]]},{"id":"17770206.6f797e","type":"function","z":"5798032a.fc88ac","name":"Ustawiam zapisaną stację","func":"var stacja = flow.get(\"stacja\");\nvar playing = flow.get(\"playing\");\nmsg.payload =\n{\n \"data\":\n {\n \"media_content_id\":stacja,\n \"media_content_type\":playing,\n }\n}\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":850,"y":620,"wires":[["1488e178.ff079f"]]},{"id":"1488e178.ff079f","type":"api-call-service","z":"5798032a.fc88ac","name":"Ustawiam stację","server":"","version":1,"debugenabled":true,"service_domain":"media_player","service":"play_media","entityId":"media_player.lazienka","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1060,"y":620,"wires":[[]]},{"id":"bd37ef7d.d2e4","type":"api-call-service","z":"5798032a.fc88ac","name":"Głosnik Łazienka","server":"","version":1,"debugenabled":false,"service_domain":"tts","service":"google_translate_say","entityId":"media_player.lazienka","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":820,"y":510,"wires":[["4f128c65.e10e64"]]},{"id":"553bdff9.b3ce3","type":"switch","z":"5798032a.fc88ac","name":"Grało?","property":"playing","propertyType":"flow","rules":[{"t":"eq","v":"music","vt":"str"},{"t":"neq","v":"music","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":620,"wires":[["bff67f79.50c5e","17770206.6f797e"],["bff67f79.50c5e"]]},{"id":"d98d9263.2a205","type":"api-current-state","z":"5798032a.fc88ac","name":"","server":"","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"media_player.lazienka","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1220,"y":510,"wires":[["40f91799.5d3fb8"]]},{"id":"40f91799.5d3fb8","type":"switch","z":"5798032a.fc88ac","name":"","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"idle","vt":"str"},{"t":"eq","v":"idle","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1460,"y":510,"wires":[["3d73b548.d1847a"],["553bdff9.b3ce3"]]},{"id":"3d73b548.d1847a","type":"delay","z":"5798032a.fc88ac","name":"500 Milisekund","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1330,"y":430,"wires":[["d98d9263.2a205"]]},{"id":"4f128c65.e10e64","type":"delay","z":"5798032a.fc88ac","name":"3 sekundy","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":990,"y":510,"wires":[["d98d9263.2a205"]]},{"id":"4f7d7e7a.e97f6","type":"function","z":"5798032a.fc88ac","name":"msg.payload= msg.komunikat","func":"msg.payload= msg.komunikat\n \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":570,"y":510,"wires":[["bd37ef7d.d2e4"]]},{"id":"9a70bd34.a42d5","type":"change","z":"5798032a.fc88ac","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":370,"wires":[["a93c2f13.d52d8"]]},{"id":"851734a0.b02358","type":"delay","z":"5798032a.fc88ac","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":760,"y":210,"wires":[["9a70bd34.a42d5"]]}]
Ostatnio zrobiłem bardzo dużo automatyzacji i teraz sobie pomyślałem że jeszcze prościej to można zrobić, a w zasadzie juz prościej i lepiej sie nie da nodem wait until, radio gra natychmiast po komunikacie
[{"id":"5798032a.fc88ac","type":"tab","label":"test","disabled":false,"info":""},{"id":"1d8d0d37.9b9403","type":"api-call-service","z":"5798032a.fc88ac","name":"Ustawienie głośności","server":"","version":1,"debugenabled":true,"service_domain":"media_player","service":"volume_set","entityId":"media_player.biuro","data":"{\"volume_level\":\"0.5\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":330,"y":510,"wires":[["4f7d7e7a.e97f6"]]},{"id":"34f1138c.fdf04c","type":"delay","z":"5798032a.fc88ac","name":"100 milisekund","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":140,"y":510,"wires":[["1d8d0d37.9b9403"]]},{"id":"3c9b8a2c.9264b6","type":"api-call-service","z":"5798032a.fc88ac","name":"Głośnik STOP","server":"","version":1,"debugenabled":true,"service_domain":"media_player","service":"media_stop","entityId":"media_player.biuro","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":990,"y":370,"wires":[["34f1138c.fdf04c"]]},{"id":"9c317b29.1b9be8","type":"change","z":"5798032a.fc88ac","name":"Zapisuję na boku 3","rules":[{"t":"set","p":"glosnosc","pt":"flow","to":"data.attributes.volume_level","tot":"msg"},{"t":"set","p":"playing","pt":"flow","to":"music","tot":"str"},{"t":"set","p":"stacja","pt":"flow","to":"data.attributes.media_content_id","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":370,"wires":[["3c9b8a2c.9264b6"]]},{"id":"c59974ca.a211f8","type":"change","z":"5798032a.fc88ac","name":"Zapisuję na boku 1","rules":[{"t":"set","p":"glosnosc","pt":"flow","to":"data.attributes.volume_level","tot":"msg"},{"t":"set","p":"playing","pt":"flow","to":"off","tot":"str"},{"t":"set","p":"stacja","pt":"flow","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":330,"wires":[["3c9b8a2c.9264b6"]]},{"id":"e51a7f79.7f9e7","type":"switch","z":"5798032a.fc88ac","name":"Gra?","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"playing","vt":"str"},{"t":"eq","v":"playing","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":640,"y":370,"wires":[["c59974ca.a211f8"],["9c317b29.1b9be8"]]},{"id":"a93c2f13.d52d8","type":"api-current-state","z":"5798032a.fc88ac","name":"Pobieram dane głośnika","server":"","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"media_player.biuro","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":460,"y":370,"wires":[["e51a7f79.7f9e7"]]},{"id":"aa420fcd.1eb12","type":"api-call-service","z":"5798032a.fc88ac","name":"Ustawiam głośność","server":"","version":1,"debugenabled":true,"service_domain":"media_player","service":"volume_set","entityId":"media_player.biuro","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1090,"y":660,"wires":[[]]},{"id":"bff67f79.50c5e","type":"function","z":"5798032a.fc88ac","name":"Ustawiam zapisaną głosność","func":"var glosnosc = flow.get(\"glosnosc\");\nmsg.payload =\n{\n \"data\":\n {\n \"volume_level\":glosnosc,\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":860,"y":660,"wires":[["aa420fcd.1eb12"]]},{"id":"17770206.6f797e","type":"function","z":"5798032a.fc88ac","name":"Ustawiam zapisaną stację","func":"var stacja = flow.get(\"stacja\");\nvar playing = flow.get(\"playing\");\nmsg.payload =\n{\n \"data\":\n {\n \"media_content_id\":stacja,\n \"media_content_type\":playing,\n }\n}\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":850,"y":620,"wires":[["1488e178.ff079f"]]},{"id":"1488e178.ff079f","type":"api-call-service","z":"5798032a.fc88ac","name":"Ustawiam stację","server":"","version":1,"debugenabled":true,"service_domain":"media_player","service":"play_media","entityId":"media_player.biuro","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1060,"y":620,"wires":[[]]},{"id":"bd37ef7d.d2e4","type":"api-call-service","z":"5798032a.fc88ac","name":"Głosnik Łazienka","server":"","version":1,"debugenabled":false,"service_domain":"tts","service":"google_translate_say","entityId":"media_player.biuro","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":820,"y":510,"wires":[["4f128c65.e10e64"]]},{"id":"553bdff9.b3ce3","type":"switch","z":"5798032a.fc88ac","name":"Grało?","property":"playing","propertyType":"flow","rules":[{"t":"eq","v":"music","vt":"str"},{"t":"neq","v":"music","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":620,"wires":[["bff67f79.50c5e","17770206.6f797e"],["bff67f79.50c5e"]]},{"id":"4f128c65.e10e64","type":"delay","z":"5798032a.fc88ac","name":"2 sekundy","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":990,"y":510,"wires":[["47e89a0f.6c9d34"]]},{"id":"4f7d7e7a.e97f6","type":"function","z":"5798032a.fc88ac","name":"msg.payload= msg.komunikat","func":"msg.payload= msg.komunikat\n \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":570,"y":510,"wires":[["bd37ef7d.d2e4"]]},{"id":"9a70bd34.a42d5","type":"change","z":"5798032a.fc88ac","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":370,"wires":[["a93c2f13.d52d8"]]},{"id":"851734a0.b02358","type":"delay","z":"5798032a.fc88ac","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":240,"y":330,"wires":[["9a70bd34.a42d5"]]},{"id":"5744d43e.abd5ac","type":"function","z":"5798032a.fc88ac","name":"KOMUNIKAT","func":"msg.komunikat=\n{\n \"data\":\n {\n \"message\": \" To jest wiadomość testowa!\",\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":390,"y":100,"wires":[["851734a0.b02358"]]},{"id":"670dd82c.4d1998","type":"inject","z":"5798032a.fc88ac","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":90,"wires":[["5744d43e.abd5ac"]]},{"id":"47e89a0f.6c9d34","type":"ha-wait-until","z":"5798032a.fc88ac","name":"","server":"","outputs":1,"entityId":"media_player.lazienka","entityIdFilterType":"exact","property":"state","comparator":"is","value":"idle","valueType":"str","timeout":0,"timeoutType":"num","timeoutUnits":"seconds","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":1150,"y":510,"wires":[["553bdff9.b3ce3"]]}]
coś się mi to wysypuje w połowie… twója wiadomość idzie jako msg.payload czy jako msg.komunikat? może w tym mam problem?
zobacz poniżej,
mam tak że umieszczam wiadomość przed subwezlem głośnika i jak wpada do głośnika to bezpośrednio przed wysłaniem wiadomości na głośnik w msg.playload wpisuję ten mój msg.komunikat,
pobierz sobie ten flow z ostatniego posta, jest tam tez funkcja komunikat…
masz undefined bo nie miales wczesniej ustalonego msg.komunikat… rozumiesz?
faktycznie, dzięki, jak zmieniłem u siebie wadomość z msg.payload na msg.komunikat to działa, potestuję trochę twoje rozwiązanie.
Flow z tego postu działa u mnie idealnie. Głośnik to Google Home Mini. Męczyłem się któryś tydzień z rozkminą tego tematu Dzięki za rozwiązanie ! Z wrażenia zrobiłem od razu 6 subflow z różnymi głośnościami
Kurcze, a tak z ciekawości - bo nie rozumiem - w swoim flow zapisujesz na boku trzy zmienne flow.glosnosc, flow.playing i flow.stacja, ale nie widzę ich tam gdzie jest Context Data. Potem je przywołujesz na końcu w zmiennych var stacja i var playing. Ale skąd skoro ich we flow nie ma ?
Zobacz “zapisuje na boku 3” tam masz “data.attributes.media_content_id” zapisane do flow.stacja… Czy chodzi Ci o cos innego?
Dobra robota, pewnie to przetestuję w najbliższym czasie. Rozumie że działa tylko na radiu, czy inne odtwarzacze też, np. Spotify?
jest to w mojej ocenie nie do zrobienia w ten sposob,
masz usluge spotify która leci z podłączonego konta spotify i musiałbyś wysłać nie do glosnika ale do spotify aby kontynuował,
w teorii można wyciągnąc tytuł odtwarzanego utworu i moze jest sposob rednode>>spotify, ale nie szukałem tego jeszcze,
ew. mozesz wycianac utwór i wysłać do google assistanta zeby wlaczył ten utwór…może przez webhook i iftt… gruby temat nie wiem czy do zrobienia
W sumie możesz mieć rację, ciężko to będzie zrobić.
Zastanawiam się jeszcze nad przywróceniem głośności jak jest wyłączony głośni, żeby przy włączeniu nie włączył się na maksymalnej głośności.
No to jest w tym flow,
pobieram starą głośność, ustawiam nową i na koniec wprowadzam starą
Aaa ok, to muszę koniecznie przetestować. Dzięki
Dokładnie o to mi chodzi.
Wartość “data.attributes.media_content_id” zapisujesz do zmiennej "flow.stacja ", której wartość można zobaczyć z boku w rozwijalnym menu “Context data”. W każdym innym flow u siebie mogę to zobaczyć
W Twoim flow już nie
Nie wiem dlaczego tak jest. Moje pytanie dotyczy jednak raczej samej obsługi Node-Red niż Twojego konkretnego flow.
Ja ma tam pełny także nie wiem co Ci się tam popsuło
odśwież całe, uruchom proces i odśwież
Dziwne, ale restarty całego NR i HA nic nie dały. Skopiowałem jeszcze raz cały flow z Twojego postu i o dziwo po imporcie te zmienne oczywiście tam są Nie żeby mi to w życiu specjalnie przeszkadzało, bo jak pisałem cały flow działał i działa idealnie ale wolę wiedzieć co i jak. Pozdrawiam i dzięki.
kiedyś zauważyłem, że jakiś proces nie pokazywał mi żadnych wskazań ale działał, po restarcie NodeRed zaczęło wszystko prawidłowo odczytywać, tak jak by NodeRed złapał jakiegoś buga
Hej,
a czy zapamietanie tych zmiennych
volume_level: 0.4545454680919647
is_volume_muted: false
media_content_id: spotify:track:75FEaRjZTKLhTrFGsfMUXR
media_content_type: music
media_duration: 298.957
media_position: 85.338
media_position_updated_at: 2021-02-18T21:44:29.712575+00:00
media_title: Running Up That Hill (A Deal With God)
media_artist: Kate Bush
media_album_name: Hounds Of Love
app_id: CC32E753
app_name: Spotify
entity_picture_local: /api/media_player_proxy/media_player.salon?token=8e75b9583ebf915a9b35d3ea078b416afd759c310aae8bbd06853e8e6ee966e5&cache=d22f3f4ccd6ad703
friendly_name: Glosnik Salon
entity_picture: https://i.scdn.co/image/ab67616d00001e0296ab64f52273635308b6bf27
supported_features: 152511
I potem odtworzenie komunikatu
i znow wypelnienei zadziala na spotify ?
Dołączam sie do pytania. Ma ktoś jakiś nowy pomysł na wznawianie Spotify ?