Fun with Mycroft and Home Assistant!

Not sure if this is the right category. Please move if it belongs somewhere else.

I’ve been using Mycroft for over a year now. He’s still booting from microSD but I’m going to do a USB boot this weekend. That said, I’ve been integrating him more and more into my Home Assistant ecosystem. I figured I’d share some automations that utilize Mycroft. Of course, you can always just call scenes by saying turn on this or that, or call automations by saying activate this or that. Then, of course, you can just trigger individual devices and sensors by their own friendly name. These automations make Mycroft feel like he’s actually alive and part of the home. Some are little tongue in cheek, and more for my own personal pleasure. I’m going to post each one as a new comment to this original post. If you have any questions with the integration, feel free to ask. And have fun!

9 Likes

Hopefully now, I will never forget to charge my phone. At least, Mycroft won’t let me…

alias: ChargeYourPhone
description: ''
trigger:
  - type: battery_level
    platform: device
    device_id: 52ea4cf51e484a766db41226624686c6
    entity_id: sensor.pixel6_battery_level
    domain: sensor
    below: 16
condition:
  - condition: zone
    entity_id: device_tracker.pixel6
    zone: zone.home
action:
  - service: notify.picroft
    data:
      message: (yournamehere), you need to charge your phone.
  - delay:
      hours: 0
      minutes: 2
      seconds: 0
      milliseconds: 0
  - condition: state
    entity_id: sensor.pixel6_battery_state
    state: discharging
  - service: notify.picroft
    data:
      message: Please begin charging your phone.
  - delay:
      hours: 0
      minutes: 2
      seconds: 0
      milliseconds: 0
  - condition: state
    entity_id: sensor.pixel6_battery_state
    state: discharging
  - service: notify.picroft
    data:
      message: Don't make me angry. Start charging your phone now.
mode: single

2 Likes

You don’t want to run your 3D printer filament dryer 24/7. This will turn it off after a certain amount of time and Mycroft will let you know it’s finished drying.

alias: Filament Drying
description: ''
trigger:
  - platform: device
    type: turned_on
    device_id: c38fce85af700c88ddac132c8f78fac6
    entity_id: switch.filament_dryer_socket_1
    domain: switch
    for:
      hours: 6
      minutes: 0
      seconds: 0
condition: []
action:
  - type: turn_off
    device_id: c38fce85af700c88ddac132c8f78fac6
    entity_id: switch.filament_dryer_socket_1
    domain: switch
  - service: notify.picroft
    data:
      message: The filament has finished drying.
mode: single

2 Likes

I still need to finesse the motion sensitivity of the Hue sensor, but this will alert me when the bandits are outside snooping around my property.

alias: Front Motion
description: ''
trigger:
  - type: motion
    platform: device
    device_id: b4c30260f0cea9f3bdfa1953276ba7f7
    entity_id: binary_sensor.hue_outdoor_motion_sensor_1_motion
    domain: binary_sensor
condition:
  - condition: time
    before: input_datetime.motionstop
    after: input_datetime.motionstart
action:
  - service: light.toggle
    data:
      flash: short
    target:
      entity_id:
        - light.livingroom1
        - light.livingroom2
        - light.hue_white_lamp_1_2
        - light.hue_white_lamp_1
  - repeat:
      count: '2'
      sequence:
        - type: toggle
          device_id: a2caea58b4772b83dd72bcf1366c07a4
          entity_id: switch.30375283c4dd57371202
          domain: switch
  - service: notify.picroft
    data:
      message: Motion sensed on front porch.
mode: single

3 Likes

Mycroft tells me to have a good day, before I leave.

alias: HaveALovelyDay
description: ''
trigger:
  - platform: event
    event_data:
      domain: scene
      service: turn_on
      service_data:
        entity_id: scene.leaving_home
    event_type: call_service
condition: []
action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: notify.picroft
    data:
      message: Have a lovely day!
mode: single

1 Like

Regarding the front motion sensor, you don’t want to let it run out of batteries. This could work on any battery operated device, that issues a state of its own battery level.

alias: FrontMotionBattery
description: ''
trigger:
  - type: battery_level
    platform: device
    device_id: b4c30260f0cea9f3bdfa1953276ba7f7
    entity_id: sensor.frontmotion_battery
    domain: sensor
    below: 16
condition: []
action:
  - service: notify.picroft
    data:
      message: Front Motion battery is getting low.
  - service: notify.mobile_app_pixel6
    data:
      title: BATTERY ALERT!!
      message: Time to change the battery in front motion sensor.
mode: single

1 Like

For my own guilty pleasure, Mycroft gives me positive feedback when I remember to charge my phone…

alias: MycroftThanksYou
description: ''
trigger:
  - platform: state
    entity_id: sensor.pixel6_battery_state
    to: charging
    from: discharging
condition:
  - condition: zone
    entity_id: device_tracker.pixel6
    zone: zone.home
action:
  - service: notify.picroft
    data:
      message: You are so responsible, (yournamehere).
mode: single

1 Like

And of course, you don’t want to leave your phone continually on the charger. My good buddy Mycroft is there to remind me that I can begin discharging the battery again.

alias: PhoneIsCharged
description: ''
trigger:
  - type: battery_level
    platform: device
    device_id: 52ea4cf51e484a766db41226624686c6
    entity_id: sensor.pixel6_battery_level
    domain: sensor
    above: 95
condition:
  - condition: zone
    entity_id: device_tracker.pixel6
    zone: zone.home
  - condition: state
    entity_id: sensor.pixel6_battery_state
    state: charging
  - condition: device
    type: is_off
    device_id: 256b1be04f12d1acdbe125b15e938268
    entity_id: switch.bedcharge_socket_1
    domain: switch
action:
  - service: notify.picroft
    data:
      message: (yournamehere), your phone is charged.
  - delay:
      hours: 0
      minutes: 3
      seconds: 0
      milliseconds: 0
  - condition: state
    entity_id: sensor.pixel6_battery_state
    state: charging
  - service: notify.picroft
    data:
      message: Please remove your phone from the charger.
  - delay:
      hours: 0
      minutes: 3
      seconds: 0
      milliseconds: 0
  - condition: state
    entity_id: sensor.pixel6_battery_state
    state: charging
  - service: notify.picroft
    data:
      message: Are you ignoring me? Your phone is fully charged.
mode: single

2 Likes

I’ve created a monster…My lovely lady cannot fathom cooking the rice anymore without this automation.

alias: Rice Cooking
description: ''
trigger:
  - platform: device
    type: turned_on
    device_id: d824ea748dfbfd1fdd88ae49fc092faa
    entity_id: switch.therice_socket_1
    domain: switch
    for:
      hours: 0
      minutes: 20
      seconds: 0
condition: []
action:
  - type: turn_off
    device_id: d824ea748dfbfd1fdd88ae49fc092faa
    entity_id: switch.therice_socket_1
    domain: switch
  - service: notify.picroft
    data:
      message: The rice has finished cooking.
mode: single

2 Likes

And after a hard day at work, at least someone is happy to see me. Usually my dog is, and I’m pretty sure my lovely lady is too… But just in case they’re both mad at me for some reason I can trust that Mycroft won’t be.

alias: WelcomeBackHome
description: ''
trigger:
  - platform: event
    event_data:
      domain: scene
      service: turn_on
      service_data:
        entity_id: scene.back_home
    event_type: call_service
condition: []
action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: notify.picroft
    data:
      message: Welcome back. I hope you had a good day.
mode: single

2 Likes

Last, but not least. With work out of my thoughts, while at home, I’m reminded twice a week to charge my tool batteries. I hate being in a repair situation and something doesn’t work because I forgot to charge the dang battery! I’m sure there will be more automations along the way, but this is most of what I have so far.

alias: WorkTruckBatteries
description: ''
trigger:
  - platform: time
    at: input_datetime.worktruckbatteries
condition:
  - condition: time
    before: '00:00:00'
    after: '17:00:00'
    weekday:
      - wed
      - sun
action:
  - service: notify.picroft
    data:
      message: 'You need to charge your work truck batteries '
  - service: notify.mobile_app_pixel6
    data:
      title: BATTERY REMINDER
      message: >-
        You need to go back outside to your truck, gather all the batteries, and
        charge them. 
mode: single

2 Likes

So COOL!!!

Keep those snippets coming. :muscle:

2 Likes

lol they are great - that Mycroft can be a demanding master too!

1 Like

If I have a mark 2 will home automation detect the camera on it?

Hi, big fan of HomeAssistant.

I can’t get mine connected however… I receive this error:
“MycroftAPI’ object has no attribute '_ws”

They are on the same network/VLAN/Subnet.

Any ideas?

1 Like

That might be a question for the home assistant people. I’m not sure exactly how the skill integrates with mycroft. I didn’t make the skill but if the camera could somehow be released as an rtsp stream on your network then it could be dumped into home assistant.

1 Like

Did you build your own Mycroft or are you using a Mark 2? I’m using the Picroft enclosure. I wonder if there’s something different with the Mark 2.

The setup is pretty simple. You just need to point the Mycroft host in your configuration.yaml and then also in the notify section for Mycroft to receive notifications. You also need to make sure and go to the home.mycroft.ai web page and plug in your home assistant url/ or IP. That’s where you customize all your skills.

Sorry if you already know and did this. Also make sure you’re not using some sort of DNS forwarding and forgot about it. I’m using a DuckDNS URL for home assistant and I also have my router resolving that internally on the home network. So nothing at home points to the static IP address of Home assistant but the actual domain name.

Mark 2. My config looks good, and token has been properly generated.

The funny part is… It worked on Classic WITHOUT a token. Does not work on Dinkum with the token

configuration.yaml:

mycroft:
host: 192.168.93.104

notify:

  • platform: mycroft
    name: Mycroft

So assuming it’s a bug on Dinkum at this point…

The Mark ii’s home assistant skill does not use the old integration.

The new skill operates 100% on the mycroft and talks to the HA server over the API, no configuration changes in HA are necessary.

The snippets nerlins has posted will not work on the Mark ii. Currently there is no way to send notifications from HA to the new HA mycroft skill on the Mark ii, I’ve opened a feature request here: Sending notifications from HA to the mycroft · Issue #115 · MycroftAI/skill-homeassistant · GitHub

more info here: Mycroft Mark II with Home Assistant - #2 by goldyfruit

Well that certainly explains why Classic works and Dinkum does not.

Another disappointment… Appreciate your reply though!