HA + Homekit

Hello,
Hi
Have searched everywhere but not found any explanation, therefore I write if there is anyone who knows about this.

Is it possible to send a card from HA to the homekit. Given that everyone in the family should be able to use it.

Thanks

Hello @Jojjes,

what do you mean with “card”?

Greetings Sirez

Thanks for reply

Like this one is a Lovelace card

What is exactly behind that “food” card? You can’t pass a card to Homekit, what you could do is pass their entites. But you have to configure it through yaml.
Example:

homekit:    
  include_entities:
      - binary_sensor.living_room_motion

More explanaition here:

Hope I got your point, if not feel free to ask again, I’ll reply as soon as possible. :slight_smile:

Sirez

Hi

This is behind.

type: entity-button
hold_action:
action: food
icon: haas:bell
icon_height: 50px
name: Food
show_icon: true
show_name: true
tap_action:
action: call-service
service: tts.google_translate_say
service_data:
entity_id: all
volum_set: 0.05
language: sv
message: Food

you cannot pass services to HomeKit. You can only pass the entities/integrations listed as supported in the HA HomeKit integration.

What you could do is create a dummy switch that you can expose in HomeKit, then in HA create an automation that calls the same tts service that your “food” card calls.

1 Like

Okej, iam new to this and i don’t know how to make this?

You could use an Input Boolean.

Add this to your config:

input_boolean: ""

Restart HA

After this you can create helper variables: Configuration -> Helpers
grafik

And then you can create a new automation which calls the service.

After this don’t forget to add it to your homekit integration config!

homekit:
  filter:
    include_entities:
      - input_boolean.callservice

or if you plan to use more boolean helpers include the whole domain

homekit:
  filter:
    include_domains:
      - input_boolean

Hi again,

Thanks i will try this. I have also on more question about this, is some way to remove from all sonos speaker food sound after it was send.

In your automation action you should do the following actions in order:

  • Sonos snapshot with group
  • Sonos join/unjoin depending which speakers you want to play the sound
  • media player set volume
  • TTS say service or other media player play media service
  • wait template to wait until the speaker is done playing (wait until state is paused)
  • Sonos restore with group

I’ll update later with what my automation action section looks like.

This sequence snapshots whatever was playing before the message, plays your message, then restores the state before the message.

EDIT: Here’s my automation action that speaks to all of my Sonos speakers then restores their previous state

    - service: sonos.snapshot
      data:
        entity_id:
        - media_player.kitchen
        - media_player.living_room
        with_group: true
    - service: sonos.join
      data:
        master: media_player.kitchen
        entity_id: media_player.living_room
    - service: media_player.volume_set
      data:
        entity_id:
        - media_player.kitchen
        - media_player.living_room
        volume_level: 0.7
    - service: tts.google_translate_say
      data_template:
        entity_id: media_player.kitchen
        message: >
          The National Weather Service has issued a {{ state_attr('sensor.nws_alerts','spoken_desc').split('\n\n-\n\n')[0] }} for our area.
    - delay:
        seconds: 2
    - wait_template: "{{ is_state('media_player.kitchen','paused') }}"
    - service: sonos.restore
      data:
        entity_id:
        - media_player.kitchen
        - media_player.living_room
        with_group: true

EDIT 2: You don’t have to do the Sonos join. You can always provide the tts service or the play_media service with a list of entities like:

entity_id:
- media_player.player_1
- media_player.player_2
- media_player.player_3
...

Hi i recive 2 errors

food: Error executing script. Invalid data for call_service at pos 1: extra keys not allowed @ data[‘volum_set’]

And

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/automation/init.py”, line 409, in async_trigger
await self.action_script.async_run(variables, trigger_context)
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 790, in async_run
await asyncio.shield(run.async_run())
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 185, in async_run
await self._async_step(log_exceptions=False)
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 193, in _async_step
await getattr(
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 382, in _async_call_service_step
await service_task
File “/usr/src/homeassistant/homeassistant/core.py”, line 1235, in async_call
processed_data = handler.schema(service_data)
File “/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py”, line 272, in call
return self._compiled([], data)
File “/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py”, line 594, in validate_dict
return base_validate(path, iteritems(data), out)
File “/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py”, line 432, in validate_mapping
raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: extra keys not allowed @ data[‘volum_set’]

Please post the full script, the full error log and format both properly in your post.

EDIT: it needs to be volume_set You’re missing the e in volume.

this is one

Log Details (ERROR)

Logger: homeassistant.components.automation
Source: helpers/script.py:200
Integration: Automation (documentation, issues)
First occurred: 1:44:51 PM (1 occurrences)
Last logged: 1:44:51 PM

food: Error executing script. Invalid data for call_service at pos 1: extra keys not allowed @ data[‘volume_set’]

and the other

Log Details (ERROR)

Logger: homeassistant.components.automation
Source: core.py:1235
Integration: Automation (documentation, issues)
First occurred: 1:44:51 PM (1 occurrences)
Last logged: 1:44:51 PM

While executing automation automation.food

Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/automation/init.py”, line 409, in async_trigger await self.action_script.async_run(variables, trigger_context) File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 790, in async_run await asyncio.shield(run.async_run()) File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 185, in async_run await self._async_step(log_exceptions=False) File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 193, in _async_step await getattr( File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 382, in _async_call_service_step await service_task File “/usr/src/homeassistant/homeassistant/core.py”, line 1235, in async_call processed_data = handler.schema(service_data) File “/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py”, line 272, in call return self._compiled([], data) File “/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py”, line 594, in validate_dict return base_validate(path, iteritems(data), out) File “/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py”, line 432, in validate_mapping raise er.MultipleInvalid(errors) voluptuous.error.MultipleInvalid: extra keys not allowed @ data[‘volume_set’]

post the full script, otherwise we’re guessing what’s wrong. and post it in preformatted text by pressing the </> button and pasting between the back ticks.

with script? this one?

  • id: ‘1596453658459’
    alias: food
    description: ‘’
    trigger:
    • entity_id: input_boolean.callservice
      platform: state
      to: ‘on’
      condition: []
      action:
    • data:
      entity_id:
      • media_player.vardagsrum
      • media_player.antonys_rum
        language: sv
        message: food
        volume_set: 0.05
        service: tts.google_translate_say
        mode: single

edit. this is all I have

I don’t think this service can take the volume_set: 0.05 option. I could be wrong though.

Hi

know is working this way, I want to put in that after is restoring to before playlist

  • id: ‘1596453658459’
    alias: food
    description: ‘’
    trigger:
    • entity_id: input_boolean.callservice
      from: ‘off’
      platform: state
      to: ‘on’
      condition:
      action:
    • data:
      entity_id: group.ljud
      language: sv
      message: mat
      service: tts.google_translate_say
      mode: single

I think you should start a new thread as this has nothing to do with the original post.
But even better imo would be if you start playing around with the Developer Tools, read the Docs and try to understand how everything glues together smoothly to your needs. :slight_smile:

thanks for everything

You’re welcome mate!