Magic Mirror Control From HA

This Is Mark 1 verson have to start somewhere

Built this verson as a package

can turn screen on/off

sensor to show if its on/off

can reboot it

or

shut it down

#=======================================================================
# Do a FIND REPLACE
# MMIPADDRESS with the the magicMirror ipaddress ???.???.???.???
#=======================================================================
homeassistant:
  customize:
    package.node_anchors:
     customize: &customize
       package: 'Magic Mirror' 

    sensor.mm_display:
      icon: mdi:monitor
      friendly_name: Mirror Display
    switch.mm_display:
      icon: mdi:monitor
      friendly_name: Mirror Display
    script.mm_reboot:
      icon: mdi:lock-reset
    script.mm_shutdown:
      icon: mdi:power

sensor:
  - platform: rest
    resource: http://MMIPADDRESS:8080/remote?action=MONITORSTATUS
    name: mm display
    value_template: '{{ value_json.monitor }}'
#=======================================================================
#
#=======================================================================
switch:
  - platform: command_line
    switches:
      mm_display:
        command_on: "curl -s 'http://MMIPADDRESS:8080/remote?action=MONITORON'"
        command_off: "curl -s 'http://MMIPADDRESS:8080/remote?action=MONITOROFF'"

#=======================================================================
#
#=======================================================================
shell_command:
  mm_reboot: "curl -s 'http://MMIPADDRESS:8080/remote?action=REBOOT'"
  mm_shutdown: "curl -s 'http://MMIPADDRESS:8080/remote?action=SHUTDOWN'"
#=======================================================================
#
#=======================================================================
script:
  mm_reboot:
    alias: Magic Mirror Reboot
    sequence:
    - data: {}
      service: shell_command.mm_reboot
  mm_shutdown:
    alias: Magic Mirror ShutDown
    sequence:
    - data: {}
      service: shell_command.mm_shutdown   

all you need to is put above code into a file inside the package folder

do a find replace MMIPADDRESS with the IPaddress of the Magic Mirror

and the mirror MUST have This module in it

Leaning how to send message to the mirror will update when I know

the lovelace BIT

image

      - type: entities
        show_header_toggle: false
        title: "Magic Mirror"
        entities:
          - switch.mm_display
          - entity: sensor.mm_display
            name: Mirror Display 
          - script.mm_reboot
          - script.mm_shutdown

if you dont know what magic mirror is

https://magicmirror.builders/

using my old PI which was HASS got HASS on real PC now

6 Likes

Been thinking more about this. Think I need to lean some python and write my own plugin
we dont where to start tho

i did get this this working today

import json
import urllib.request
module_data = urllib.request.urlopen('http://IPADDRESS:8080/remote?action=MODULE_DATA')
modules = json.loads(module_data.read())
print(modules)
for module in modules["moduleData"]:
        print(module["name"] )
        print(module["hidden"])

which list the module i have loaded


happy with
was thinking put that into a input select and getting HA to turn hide them

can some point me down the right manual to read

added ====== 27/06/18
found this post

group_entities = hass.states.get('group.all_lights').attributes['entity_id']
all_lights = []
for e in group_entities:
    all_lights.append(e)
service_data = {'entity_id': 'input_select.timer_generico7',
                'options': all_lights}
hass.services.call('input_select', 'set_options', service_data)

run it and it worked
so …
got me thinking

import json
import urllib.request
module_data = urllib.request.urlopen('http://blabla:8080/remote?action=MODULE_DATA')
modules = json.loads(module_data.read())
my_modules = []
for module in modules["moduleData"]:
        my_modules.append(module["name"])
service_data = {'entity_id': 'input_select.mm_modules',
                'options': my_modules}
hass.services.call('input_select', 'set_options', service_data)

all I got was

:frowning:

where the manual when you need it
look like you can’t import modules

so delete the import still not working

one good thing less error lines LOL

after more read found out you can’t import :frowning:

1 Like