[-] bazingabot@lemmy.world 1 points 11 hours ago

In dem es aus Deutschland und der EU austritt...🤣

[-] bazingabot@lemmy.world 1 points 2 days ago

Meta tells that it pauses it...but do you know for sure? Basically, you can't trust anything they state.

[-] bazingabot@lemmy.world 32 points 1 week ago

Definitely not my representatives in the EU..and all in front our wonderful Ursula von der Leyen, a personified political failure. And why this constant fake argument of child abuse?.. the real argument is that politicians and governments want to spy on EU inhabitants..time to vote differently..if this still helps anything in the EU ..

1

Hi, want to share my script how you make a good tts announcement on sonos.

How it works:

  • triggered by an automation like this
          - service: script.turn_on
            entity_id: script.jarvis_speak
            data:
              variables:
                mymessage: |
                  {{ state_attr('sensor.notification_message', 'msg') }}
                myplayer: media_player.sonos_bedroom

  • the script is using an input_boolean to flip so that one announcement is done at a time, that's why I have the "jarvis_announcement_wait" boolean
  • it uses "input_number.jarvis_<>_volume to be able to adjust the volume per room for the announcements
  • it uses a little "ding" sound prior to the announcement
  • it uses piper and with trial end error I figured out how many word per minute "ryan" is speaking so that the script ends exactly at the time when the tts announcement has finished in case there are multiple announcements to be made per room
alias: jarvis_speak
sequence:
	  - repeat:
		  while:
			- condition: state
			  entity_id: input_boolean.jarvis_announcement_wait
			  state: "on"
		  sequence:
			- delay:
				hours: 0
				minutes: 0
				seconds: 1
				milliseconds: 0
	  - service: input_boolean.turn_on
		target:
		  entity_id:
			- input_boolean.jarvis_announcement_wait
		data: {}
      - service: media_player.play_media
        data:
          media_content_id: /local/jarvis-chime.wav
          media_content_type: music
          announce: true
          extra:
            volume: >-
              {{ states('input_number.jarvis_' + myplayer |
              replace('media_player.','') + '_volume')  }}
        target:
          entity_id: "{{ myplayer }}"
      - delay:
          seconds: 1
      - service: media_player.play_media
        data:
          media_content_type: music
          announce: true
          media_content_id: >-
            media-source://tts/tts.piper?message={{ mymessage  | replace('&',
            'and') }}
          extra:
            volume: >-
              {{ states('input_number.jarvis_' + myplayer |
              replace('media_player.','') + '_volume')  }}
        target:
          entity_id: "{{ myplayer }}"
      - delay:
          seconds: >
            {% set text = mymessage | replace('&', 'and') %} {{ (text.split(' ')
            | length * 60 / 150) | round(0, 'ceil') }}
	  - service: input_boolean.turn_off
		target:
		  entity_id:
			- input_boolean.jarvis_announcement_wait
		data: {}
mode: queued
max: 10

2
submitted 1 year ago* (last edited 1 year ago) by bazingabot@lemmy.world to c/homeassistant@lemmy.world

Hi,

wanted to share my recent automation. What it does: Whenever you want to watch a movie and use chromecast, it looks up the title on IMDB and gets the rating. Then announces the rating via tts.

Sorry for bad formatting - I don't get this to work here

  • Install pyscript from hacs
  • Create a pyscript folder in your config
  • In your pyscript folder create a file "requirements.txt"
  • Write "cinemagoer" and save
  • Create a file "movieinfo.py"
  • Add the following python code
from imdb import Cinemagoer

import sys

import requests

@service
def multimedia_getmovieinfos(mytitle=None):
    """yaml
    name: get imdb movie infos
    description: obtain infos from imdb for a movie, stored in multiple input_text sensors
    fields:
        mytitle:
            description: provide the movie title
            example: Rollo Aller
            required: true
"""

    ia = Cinemagoer()
    search = task.executor(ia.search_movie, mytitle)

    for i in range(len(search)):
      if i == 0:
        id = search[i].movieID
        info = task.executor(ia.get_movie, id)
        genre_list = info.data['genres']
        service.call("input_text", "set_value", blocking=True, limit=10, entity_id="input_text.multimedia_current_movie_title", value=search[i]['title'] + ' ('+str(info.data['year'])+')')
        
        service.call("input_text", "set_value", blocking=True, limit=10, entity_id="input_text.multimedia_current_movie_genre", value=','.join(map(str, genre_list)).replace(',', ', '))

        service.call("input_text", "set_value", blocking=True, limit=10, entity_id="input_text.multimedia_current_movie_rating", value=( str(round(info.data['rating'], 2))))
        
        if 'plot outline' in info.data:
            service.call("input_text", "set_value", blocking=True, limit=10, entity_id="input_text.multimedia_current_movie_plot", value=info.data['plot outline'][:255])
        else:
            service.call("input_text", "set_value", blocking=True, limit=10, entity_id="input_text.multimedia_current_movie_plot", value="no plot available")

  • Create four input_text sensors in homeassistant
input_text:

  multimedia_current_movie_title:
    name: Multimedia Current Movie Title
    
  multimedia_current_movie_rating:
    name: Multimedia Current Movie Rating
    
  multimedia_current_movie_genre:
    name: Multimedia Current Movie Genre
    
  multimedia_current_movie_plot:
    name: Multimedia Current Movie Plot
    max: 255
  • Create an input_number sensor for the rating threshold
  multimedia_tv_minimum_rating:
    name: Movie Minimum Rating
    icon: mdi:brightness-percent
    mode: slider
    step: 0.1
    max: 10
    min: 0
    initial: 5.0
  • Add an automation to trigger getting the movie infos
alias: multimedia_tv_aerocast_get_movie_infos
description: ""
trigger:
  - platform: state
    entity_id:
      - media_player.aerocast
    to: playing
    id: "1"
  - platform: state
    entity_id:
      - media_player.aerocast
    from: playing
    id: "2"
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: "1"
        sequence:
          - service: pyscript.multimedia_getmovieinfos
            data:
              mytitle: |
                {{ state_attr('media_player.aerocast', 'media_title') }}
  - choose:
      - conditions:
          - condition: trigger
            id: "2"
        sequence:
          - service: input_text.set_value
            data:
              value: " "
            target:
              entity_id: input_text.multimedia_current_movie_genre
          - service: input_text.set_value
            data:
              value: " "
            target:
              entity_id: input_text.multimedia_current_movie_title
          - service: input_text.set_value
            data:
              value: " "
            target:
              entity_id: input_text.multimedia_current_movie_rating
          - service: input_text.set_value
            data:
              value: " "
            target:
              entity_id: input_text.multimedia_current_movie_plot
mode: single




  • Add an automation to announce whenever you play your movie - I do that through mqtt. Adjust to your liking :)

alias: jarvis_notify_movie_rating
description: ""
trigger:
  - platform: state
    entity_id:
      - input_text.multimedia_current_movie_rating
condition:
  - condition: template
    value_template: "{{ states('input_text.multimedia_current_movie_rating') != ' ' }}"
action:
  - choose:
      - conditions:
          - condition: template
            value_template: >-
              {{ states('input_text.multimedia_current_movie_rating') |
              float(default=0) <
              states('input_number.multimedia_tv_minimum_rating') |
              float(default=0) }}
        sequence:
          - service: mqtt.publish
            data:
              topic: notifications
              payload_template: |
                { 
                  "heading": "Movie underrated",
                  "details":
                    { 
                      "msg": "Do you really want to watch {{ state_attr('media_player.aerocast', 'media_title') }}? It only has a rating of {{ states('input_text.multimedia_current_movie_rating') }} on I M D B.",
                      "player": "livingroom",
                      "importance": "high",
                      "received": "{{ now().strftime("%H:%M:%S") }}" 
                    }
                }
      - conditions:
          - condition: template
            value_template: >-
              {{ states('input_text.multimedia_current_movie_rating') |
              float(default=0) >=
              states('input_number.multimedia_tv_minimum_rating') |
              float(default=0) }}
        sequence:
          - service: mqtt.publish
            data:
              topic: notifications
              payload_template: |
                { 
                  "heading": "Movie well rated",
                  "details":
                    { 
                      "msg": "Nice choice for a{% if states('input_text.multimedia_current_movie_genre').split(',')[0] | lower | regex_search("[aeiou]")%}n{% endif %} {{ states('input_text.multimedia_current_movie_genre').split(',')[0] | lower }} movie. {{ state_attr('media_player.aerocast', 'media_title') }} has a rating of {{ states('input_text.multimedia_current_movie_rating') }} on I M D B.",
                      "player": "livingroom",
                      "importance": "high",
                      "received": "{{ now().strftime("%H:%M:%S") }}" 
                    }
                }
mode: single

bazingabot

joined 1 year ago