Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

U can broadcast to 1 device now. #48

Open
malosaa opened this issue Apr 3, 2022 · 11 comments
Open

U can broadcast to 1 device now. #48

malosaa opened this issue Apr 3, 2022 · 11 comments

Comments

@malosaa
Copy link

malosaa commented Apr 3, 2022

It is now possible to broadcast to 1 device.

Today i did find out how, i did say hey google, broadcast/announce to kitchen. than it asked what message and it announcec only there.

But on my phone i could use a text message so the default voice speaks instead of the tts from home assistant.

Can you implement this ?

@malosaa malosaa changed the title U can breadcast to 1 device now. U can broadcast to 1 device now. Apr 3, 2022
@chelming
Copy link

just change your broadcast message to be "to kitchen the rest of your message"

@malosaa
Copy link
Author

malosaa commented Apr 13, 2022

@malosaa
Copy link
Author

malosaa commented Apr 13, 2022

@chelming

how does it work?

@calisro
Copy link

calisro commented May 9, 2022

Unfortunately, the package runs sequentially though. So while you can broadcast to one speaker, if you call those in a loop to target say 3 of them, each appears to run sequentially and takes between 3-4 seconds before moving to the next speaker. It would be nice to fork the command to execute immediately without waiting. This isn't an automation problem (I use script.turn_on and can also recreate it from simple curl GETs)

@chelming
Copy link

chelming commented May 9, 2022

@malosaa the broadcast command isn't actually broadcasting, it's running the command "broadcast ${your message here}" so if you just change your message to "to the kitchen it's time for bed" it'll actually run "broadcast to the kitchen it's time for bed".

@calisro does google have the ability to target a specified set of speakers when using your voice? like "broadcast to kitchen and livingroom it's lunch time"?

@calisro
Copy link

calisro commented May 9, 2022

@calisro does google have the ability to target a specified set of speakers when using your voice? like "broadcast to kitchen and livingroom it's lunch time"?

No. You can hit only one at a time with a targeted 'broadcast to '. It would be nice if the package would allow parallel commands to run so that we can do that in a loop. Although I do that now, it will be sequential and very delayed across multiple speakers.

            sequence:
              - variables:
                  speakers: |
                      {{ expand(target) | map(attribute='entity_id') | list }}
              - repeat:
                  count: '{{ speakers | count }}'
                  sequence:
                    - variables:
                        speaker: '{{ speakers[repeat.index - 1] }}'
                    - choose:
                        - conditions:
                            - condition: template
                              value_template: '{{ message | length > 0 }}'
                          sequence:
                            - service: script.turn_on
                              data:
                                variables:
                                  message: >-
                                    broadcast to {{ state_attr('' ~
                                    speaker,'friendly_name') }},
                                    {{message|default('Test Message',true) }}
                              target:
                                entity_id: script.run_ga_command

I wish google would just allow broadcasts to speaker groups but that isn't available either.

@calisro
Copy link

calisro commented May 9, 2022

@malosaa the broadcast command isn't actually broadcasting, it's running the command "broadcast ${your message here}" so if you just change your message to "to the kitchen it's time for bed" it'll actually run "broadcast to the kitchen it's time for bed".

In reality, the ga_command and the ga_broadcast is exactly the same and personally i don't even bother with the broadcast one. The command is simpler and not even sure why the second command was added only to prepend the message with 'broadcast'.

class BroadcastMessage(Resource):
    def get(self):
        message = request.args.get('message', default = 'This is a test!')
        text_query = 'broadcast '+message
        response_text, response_html = assistant.assist(text_query=text_query)
        logging.debug(response_text)
        return {'status': 'OK'}

api.add_resource(BroadcastMessage, '/broadcast_message')

class Command(Resource):
    def get(self):
        message = request.args.get('message', default = 'This is a test!')
        response_text, response_html = assistant.assist(text_query=message)
        logging.debug(response_text)
        return {'status': 'OK'}

api.add_resource(Command, '/command')

To me it just adds confusion and an extra notify config in HA for zero advantage. shrugs

@chelming
Copy link

chelming commented May 9, 2022

well they're not exactly the same because broadcast prepends the message with "broadcast". I think the idea was to make it slightly shorter e.g., /broadcast "it's time for lunch" vs /command "broadcast it's time for lunch" and you could reuse the message for other notification platforms.

@calisro
Copy link

calisro commented May 9, 2022

well they're not exactly the same because broadcast prepends the message with "broadcast". I think the idea was to make it slightly shorter e.g., /broadcast "it's time for lunch" vs /command "broadcast it's time for lunch" and you could reuse the message for other notification platforms.

Its actually the same length. :)

The actual commands need to run each are (the doc is wrong, you need "message="):

http://[your.hassio.IP]:5000/broadcast_message?message=its time for lunch
http://[your.hassio.IP]:5000/command?message=broadcast its time for lunch

But yes I know the 'idea' but it's just confusing a simple thing. I'm guessing the broadcast was published first and then command was added and it was retained for backward compatibility as its missing in this initial commit.

9d8fa35

@malosaa
Copy link
Author

malosaa commented Jun 1, 2022

I use it now for all my notifications and it works as expected

@calisro
Copy link

calisro commented Jun 1, 2022

delete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants