Alya Amarsy
Published © GPL3+

Sudo - A Private by Design, Gender Neutral, Eco-friendly Bot

I built this voice enabled home elf to help me keep my house - and power consumption - under control.

IntermediateWork in progress3,768

Things used in this project

Hardware components

ReSpeaker 4-Mics Linear Array Kit
Seeed ReSpeaker 4-Mics Linear Array Kit
×1
Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
Adafruit Mono 2.5W Class D Audio Amplifier - PAM8302
×1

Software apps and online services

Snips AIR
Snips AIR
Home Assistant
Home Assistant

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Code

configuration.yaml

YAML
The Home Assistant configuration file
homeassistant:
  name: 1921
  latitude: 48.8543
  longitude: 2.3527
  elevation: 0
  unit_system: metric
  time_zone: Europe/Paris
  customize: !include customize.yaml

default_config:

sensor:
  - platform: yr
  
  - platform: history_stats    
    name: 'streetlight on today' 
    entity_id: 'light.streetlight_1'
    state: 'on'
    type: time
    start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
    end: '{{ now() }}'
    

mqtt:
  broker: 127.0.0.1
  port: 1883

snips:
  feedback_sounds: true

python_script:
      
intent_script: !include intent_script.yaml
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

#introduction:

#discovery:

intent_script.yaml

YAML
This files gives Home Assistant the instructions on how to handle each incoming intent from Snips
ikealights:
  speech:
    type: plain
    text: "OK, j'allume la lumière"
  action:
    - service: python_script.ikealights
      data_template:
        lamp_name: "{{ lamp_name }}"


consumption:
  speech:
    type: plain
    text: La lampe a passé {{ states('sensor.streetlight_on_today') }} heures allumée aujourd''hui

ikealights.yaml

YAML
This python script is invoked whenever the ikealights intent is recognized
lamp_name = data.get('lamp_name')
if lamp_name is not None:
  logger.info("turning on lamp {}".format(lamp_name))
  service_data = {'entity_id': lamp_name, 'brightness': 255 } 
  hass.services.call('light', 'turn_on', service_data, False)

Credits

Alya Amarsy

Alya Amarsy

1 project • 16 followers

Comments