Перейти к содержанию

Приглушение ТВ на время команды: различия между версиями

Материал из Wiki yaboard
Новая страница: «'''Отключение звука телевизора при общении с Алисой.''' При общении с колонкой она слышит…»
 
Нет описания правки
 
(не показано 9 промежуточных версий этого же участника)
Строка 1: Строка 1:
'''Отключение звука телевизора при общении с Алисой.'''
{{metadesc | Лайфхак: временно выключаем звук ТВ при помощи Home Assistant }}
__NOEDITSECTION__
__TOC__


При общении с колонкой она слышит в том числе и то, что говорят из телевизора. Приходится брать пульт и выключать звук вручную. Вся прелесть использования голосового помощника сходит на нет.
Нам потребуется:
Home assistent, ir remote, колонка с алисой, телевизор.
У меня не смарт тв, но имеется порт Ethernet для DLNA. В моем случае автоматизация проверяет, включен ли телевизор, чтобы не сотрясать воздух за зря. Если смарт тв и он заведен в HA, то Ir remote не понадобится.


https://youtu.be/ztIGfjLeR5U
== Проблема ==


Интеграция от AlexIT
https://github.com/AlexxIT/YandexStation
(Как тут у вас ссылкой добавить? нажимаю на понеле- добавить ссылку, заполняю форму и тишина....)
Эта интеграция умеет выдавать в HA состояние колонки. Если она имеет статус не Idle, то срабатывает цепочка в Node red. Нужно будет дополнительно создать Бинарный переключатель для этой автоматизации. Skript отправляет команду по mqtt на ir remote (прошивка Tasmota).


[[Файл:Node red.png]]
При общении с Алисой (в первую очередь в колонке) она слышит все голоса в комнате, в том числе из телевизора - и порой реагирует на неё.  


Нужно создать дополнительно один бинарный переключатель.
Приходится брать пульт и выключать звук вручную, и вся прелесть использования голосового помощника сходит на нет.
Код Node red:


== Решение ==
Нам понадобится:
* Home Assistant,
* IR-Remote,
* Колонка с алисой,
* Телевизор.
* [https://github.com/AlexxIT/YandexStation Интеграция от AlexIT]. Она умеет отдавать в HA состояние колонки. Если колонка не простаивает (статус Idle), тогда сработает цепочка в Node-RED.
* Дополнительный "Бинарный переключатель" для автоматизации: Skript отправляет команду по MQTT на IR-Remote (прошивка Tasmota).
У меня не смарт-ТВ, но имеется порт Ethernet для DLNA.
Автоматизация проверяет, включен ли телевизор, чтобы не производить ненужных действий.
Если телевизор имеет смарт-функции и заведен как устройство в Home Assistant - IR-Remote не понадобится.
[[Файл:Node red.png| Дополнительный бинарный переключатель]]
== Код Node-RED и комментарии ==
Данный код добавляется в Node-RED через импорт. Далее необходимо перенастроить ноды под свою конфигурацию. Дополнительно нужно создать бинарный переключатель tvmute в configuration.yaml
[[Файл:MuteTV-node-RED_01.png]]
[[Файл:MuteTV-node-RED_02.png]]
[[Файл:MuteTV-node-RED_03.png]]
{{#spoiler:show=Показать код | hide=Спрятать код |
<nowiki>
[{"id":"a8a2c0a1.daf508","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"66436af6.f9ed1c","type":"comment","z":"a8a2c0a1.daf508","name":"Mute TV when dialog with Alice","info":"","x":1440,"y":210,"wires":[]},{"id":"c3eff819.864418","type":"server-events","z":"a8a2c0a1.daf508","name":"1","server":"7d6bfad0.c6485c","event_type":"","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"x":50,"y":180,"wires":[["f792beef.ac22d"]]},{"id":"f792beef.ac22d","type":"api-current-state","z":"a8a2c0a1.daf508","name":"all ON","server":"7d6bfad0.c6485c","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.allautomation","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":180,"y":160,"wires":[["be6c1df.032826"],[]]},{"id":"44b5c67a.bce358","type":"api-current-state","z":"a8a2c0a1.daf508","name":"","server":"7d6bfad0.c6485c","version":1,"outputs":2,"halt_if":"IDLE","halt_if_type":"str","halt_if_compare":"is_not","override_topic":true,"entity_id":"sensor.alice_state","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":560,"y":180,"wires":[["5f582344.ad4bbc"],["1bf48208.10fb4e"]]},{"id":"d7497c6d.a3e92","type":"api-call-service","z":"a8a2c0a1.daf508","name":"turn on bool","server":"7d6bfad0.c6485c","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.tvmute","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1000,"y":150,"wires":[["29ad93ca.efa0fc"]]},{"id":"5f582344.ad4bbc","type":"delay","z":"a8a2c0a1.daf508","name":"","pauseType":"rate","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":800,"y":140,"wires":[["3e4e707e.04a01"]]},{"id":"402aaab1.31ba2c","type":"api-call-service","z":"a8a2c0a1.daf508","name":"","server":"7d6bfad0.c6485c","version":1,"debugenabled":false,"service_domain":"script","service":"toggle","entityId":"script.tv_mute","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1370,"y":150,"wires":[[]]},{"id":"3e4e707e.04a01","type":"api-current-state","z":"a8a2c0a1.daf508","name":"if bool off","server":"7d6bfad0.c6485c","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"input_boolean.tvmute","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":830,"y":190,"wires":[["d7497c6d.a3e92"],[]]},{"id":"29ad93ca.efa0fc","type":"delay","z":"a8a2c0a1.daf508","name":"","pauseType":"rate","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1170,"y":150,"wires":[["402aaab1.31ba2c"]]},{"id":"1bf48208.10fb4e","type":"delay","z":"a8a2c0a1.daf508","name":"","pauseType":"rate","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":790,"y":240,"wires":[["d4c0fc85.627888"]]},{"id":"d4c0fc85.627888","type":"api-current-state","z":"a8a2c0a1.daf508","name":"if bool on","server":"7d6bfad0.c6485c","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"input_boolean.tvmute","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":830,"y":290,"wires":[["b73d0682.a6c27"],[]]},{"id":"b73d0682.a6c27","type":"api-call-service","z":"a8a2c0a1.daf508","name":"turn off bool","server":"7d6bfad0.c6485c","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.tvmute","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":990,"y":260,"wires":[["1dc865fe.08d4d2"]]},{"id":"1dc865fe.08d4d2","type":"delay","z":"a8a2c0a1.daf508","name":"","pauseType":"rate","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1170,"y":260,"wires":[["290f54b0.0a7afc"]]},{"id":"290f54b0.0a7afc","type":"api-call-service","z":"a8a2c0a1.daf508","name":"","server":"7d6bfad0.c6485c","version":1,"debugenabled":false,"service_domain":"script","service":"toggle","entityId":"script.tv_mute","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1360,"y":260,"wires":[[]]},{"id":"be6c1df.032826","type":"api-current-state","z":"a8a2c0a1.daf508","name":"if TV is on","server":"7d6bfad0.c6485c","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"switch.tv_lg","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":320,"y":160,"wires":[["44b5c67a.bce358"],[]]},{"id":"7d6bfad0.c6485c","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]
[{"id":"a8a2c0a1.daf508","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"66436af6.f9ed1c","type":"comment","z":"a8a2c0a1.daf508","name":"Mute TV when dialog with Alice","info":"","x":1440,"y":210,"wires":[]},{"id":"c3eff819.864418","type":"server-events","z":"a8a2c0a1.daf508","name":"1","server":"7d6bfad0.c6485c","event_type":"","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"x":50,"y":180,"wires":[["f792beef.ac22d"]]},{"id":"f792beef.ac22d","type":"api-current-state","z":"a8a2c0a1.daf508","name":"all ON","server":"7d6bfad0.c6485c","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.allautomation","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":180,"y":160,"wires":[["be6c1df.032826"],[]]},{"id":"44b5c67a.bce358","type":"api-current-state","z":"a8a2c0a1.daf508","name":"","server":"7d6bfad0.c6485c","version":1,"outputs":2,"halt_if":"IDLE","halt_if_type":"str","halt_if_compare":"is_not","override_topic":true,"entity_id":"sensor.alice_state","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":560,"y":180,"wires":[["5f582344.ad4bbc"],["1bf48208.10fb4e"]]},{"id":"d7497c6d.a3e92","type":"api-call-service","z":"a8a2c0a1.daf508","name":"turn on bool","server":"7d6bfad0.c6485c","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.tvmute","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1000,"y":150,"wires":[["29ad93ca.efa0fc"]]},{"id":"5f582344.ad4bbc","type":"delay","z":"a8a2c0a1.daf508","name":"","pauseType":"rate","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":800,"y":140,"wires":[["3e4e707e.04a01"]]},{"id":"402aaab1.31ba2c","type":"api-call-service","z":"a8a2c0a1.daf508","name":"","server":"7d6bfad0.c6485c","version":1,"debugenabled":false,"service_domain":"script","service":"toggle","entityId":"script.tv_mute","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1370,"y":150,"wires":[[]]},{"id":"3e4e707e.04a01","type":"api-current-state","z":"a8a2c0a1.daf508","name":"if bool off","server":"7d6bfad0.c6485c","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"input_boolean.tvmute","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":830,"y":190,"wires":[["d7497c6d.a3e92"],[]]},{"id":"29ad93ca.efa0fc","type":"delay","z":"a8a2c0a1.daf508","name":"","pauseType":"rate","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1170,"y":150,"wires":[["402aaab1.31ba2c"]]},{"id":"1bf48208.10fb4e","type":"delay","z":"a8a2c0a1.daf508","name":"","pauseType":"rate","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":790,"y":240,"wires":[["d4c0fc85.627888"]]},{"id":"d4c0fc85.627888","type":"api-current-state","z":"a8a2c0a1.daf508","name":"if bool on","server":"7d6bfad0.c6485c","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"input_boolean.tvmute","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":830,"y":290,"wires":[["b73d0682.a6c27"],[]]},{"id":"b73d0682.a6c27","type":"api-call-service","z":"a8a2c0a1.daf508","name":"turn off bool","server":"7d6bfad0.c6485c","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.tvmute","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":990,"y":260,"wires":[["1dc865fe.08d4d2"]]},{"id":"1dc865fe.08d4d2","type":"delay","z":"a8a2c0a1.daf508","name":"","pauseType":"rate","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1170,"y":260,"wires":[["290f54b0.0a7afc"]]},{"id":"290f54b0.0a7afc","type":"api-call-service","z":"a8a2c0a1.daf508","name":"","server":"7d6bfad0.c6485c","version":1,"debugenabled":false,"service_domain":"script","service":"toggle","entityId":"script.tv_mute","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1360,"y":260,"wires":[[]]},{"id":"be6c1df.032826","type":"api-current-state","z":"a8a2c0a1.daf508","name":"if TV is on","server":"7d6bfad0.c6485c","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"switch.tv_lg","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":320,"y":160,"wires":[["44b5c67a.bce358"],[]]},{"id":"7d6bfad0.c6485c","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]
</nowiki>
}}
== Результат ==
И самое приятное, ради всего все усилия:
<youtube>ztIGfjLeR5U</youtube>
Успехов в реализации!
[[Category:Умный дом]]
[[Category:Решение проблем]]

Текущая версия от 06:20, 10 октября 2020

Проблема

При общении с Алисой (в первую очередь в колонке) она слышит все голоса в комнате, в том числе из телевизора - и порой реагирует на неё.

Приходится брать пульт и выключать звук вручную, и вся прелесть использования голосового помощника сходит на нет.

Решение

Нам понадобится:

  • Home Assistant,
  • IR-Remote,
  • Колонка с алисой,
  • Телевизор.
  • Интеграция от AlexIT. Она умеет отдавать в HA состояние колонки. Если колонка не простаивает (статус Idle), тогда сработает цепочка в Node-RED.
  • Дополнительный "Бинарный переключатель" для автоматизации: Skript отправляет команду по MQTT на IR-Remote (прошивка Tasmota).
У меня не смарт-ТВ, но имеется порт Ethernet для DLNA.
Автоматизация проверяет, включен ли телевизор, чтобы не производить ненужных действий. 
Если телевизор имеет смарт-функции и заведен как устройство в Home Assistant - IR-Remote не понадобится.


Дополнительный бинарный переключатель

Код Node-RED и комментарии

Данный код добавляется в Node-RED через импорт. Далее необходимо перенастроить ноды под свою конфигурацию. Дополнительно нужно создать бинарный переключатель tvmute в configuration.yaml

<button type="button" class="spoilers-button" aria-expanded="false">Показать код</button>

Результат

И самое приятное, ради всего все усилия:


Успехов в реализации!