Hey Manuel!
I’m a noob with Unity myself, but I’m currently walking the path @harriedegroot has so very kindly walked before us - to try and replicate his awesome Unity project.
Perhaps you already figured out how to get your smart plugs working with this setup (if so, please share!).
As a start for something that will work, albeit as somewhat of a workaround, check out the Home Assistant light switch
platform. This provides for a quick method where you simply use an existing switch
entity and create a new light
entity from that, so you can operate your switch
just as you would a light
. E.g. if your smartplug is exposed in HA as switch.manuels_smart_plug
by adding it like this (in configuration.yaml
) …
light:
- platform: switch
name: Manuels Smart Plug
entity_id: switch.manuels_smart_plug
… you’ll end up with a light.manuels_smart_plug
entity that can be turned on and off with the ususal services, and behave just like a regular light entity.
If you need more functionality, and later (as I’m planning to do), to quickly add more functionality to your Unity front end, look at the light template
platform:
# Example configuration.yaml entry
light:
- platform: template
lights:
theater_lights:
friendly_name: "Theater Lights"
level_template: "{{ state_attr('sensor.theater_brightness', 'lux')|int }}"
value_template: "{{ state_attr('sensor.theater_brightness', 'lux')|int > 0 }}"
temperature_template: "{{states('input_number.temperature_input') | int}}"
color_template: "({{states('input_number.h_input') | int}}, {{states('input_number.s_input') | int}})"
turn_on:
service: script.theater_lights_on
turn_off:
service: script.theater_lights_off
set_level:
service: script.theater_lights_level
data:
brightness: "{{ brightness }}"
set_temperature:
service: input_number.set_value
data:
value: "{{ color_temp }}"
entity_id: input_number.temperature_input
set_white_value:
service: input_number.set_value
data:
value: "{{ white_value }}"
entity_id: input_number.white_value_input
set_color:
- service: input_number.set_value
data:
value: "{{ h }}"
entity_id: input_number.h_input
- service: input_number.set_value
data:
value: "{{ s }}"
entity_id: input_number.s_input
For example, - and this has been used a lot before with the alexa_media
integration -, you can create a dimmable, templated, “utility” light, so that when you set the brightness level of your light, that actually works as a variable. For example by asking Alexa to set Fake Light to 100%, or using Unity somehow to set the brightness of Fake Light (e.g. light.fake_light
) to 100% (or 255), you then have Home Assistant react to the template light being set to 100% and perform the logic you want this to do, for example, read aloud using TTS your to-do list or which locks aren’t locked and what not. It’s a quick way to get such functionality quickly up and working in a deterministic way, while you hack away at a more permanent Python Flask-based solution, a native Amazon Skill with proper intents and such, or finalizing your proper C++ library
for your shiny Unity
openGL front-end for Home Assistant.
While we’re at it, I’m reviving this thread from June 5 this year, I’m really curious about the current state of @harriedegroot 's today after all these months. I see theres a github repo where I’m headed in 15 seconds, perhaps I’ll talk to you guys over there!