3D home navigation & control (Unity + Home Assistant)

Hey there. Finally I got my demo version finished: https://community.home-assistant.io/t/3d-app-for-home-assistant-unity-restapi-mqtt/183778. I’m using both HA.Unity and MQTT for communication. Really interesting to see 3D visualization meet HomeAssistant!!

Hi all,

I’ve managed to get the lights working with this unity addon, but I cannot work with ohter entities.
Is possible to interact with smartplugs, etc…?
How can I get the entities list from the server?

I hope you can help me with this questions.
Thanks in advance.
Manuel J. Ortega

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!

1 Like

Curious if you have any plans to make a step by step video tutorial on how to accomplish this? Amazing work!

2 Likes

hello vector could you please tell me how did you solved these in steps because home assistant refuse unity to login

Did it work with sweet home 3d?

Hi guys!

@harriedegroot: This demo is amazing! Thanks you for sharing it.
@runtimevic: It seems that I’m running into the same problem that you faced here.

Could you please help me out to figure out how to solve this? I already tried several things but I can’t solve this problem.

I double checked my url and api key and both seem to be fine. I’m also sure that I have an object collider.

When I run my Unity scene I don’t see any errors up until I click on the object. When I click on it, I see exactly the same error than @runtimevic.

The device I’m trying to turn on and off is a switch entity, but I followed the suggestion from @haakonstorm to configure it as a light entity. Still not luck!

I hope you can help me figure this out!

Hello! Where i can download the demo you are talking about? I cant see any demo for this project.

Thank you!

Hi Antonio!

I was talking about the video. Sorry for the misunderstanding.

However, if you go through the discussion, there are several resources that may help you to implement this project. Including a repo posted by @harriedegroot.

Hey, thanks for the awesome framework. Is there any way I could get in contact with the original developer? I’d like to develop this further to work with RGB and particularly switches / sliders. I’m working on a VR house integration. Managed to get the lights working with a physical button. But now I want a set of sliders or an RGB swatch to help select the colors on individual lights. The less extra coding I have to do in HA, the better. The hack mentioned of adding switches as fake lights is exactly what I’m trying to avoid… I really don’t like bloating my install files with unnecessary sudo-lights if I don’t have to. If there is anyone who can help, please message me. I’d be willing to pay for a set of scripts for the more complicated stuff, I just need something that works.

1 Like

I’m here (original developer).
Didn’t touch this project for a while, but adding additional entities & extending the light entity should be quite straightforward and doable for anyone with a little programming knowledge.

2 Likes

Hi @harriedegroot
The project you’ve done is amazing.
Could you please specify the steps to achive this? I’m not asking for too much details as it might be too much to ask. I need topics and preferebaly in order, so I know where to start and what to do next.
For example, 1. design your model in sketchup, 2. import to unity, 3. install this, 4. install that 5. do this etc.
Also if it needs some specific HA installation or docker images for any step, please specify.
And if it needs any hardware requierment please tell us.
Thank you in advance.

Hi @harriedegroot

I was going to start out something like this and wanted use your project as a guideline. Something I couldn’t find was how it will react if internet connection gets lost? Can the unity web export be implemented offline, so lights are still controllable or do you always need an internet connection for this to work?

Awesome work btw!
Thanks in advance.


Hello Iam getting this error plz can anyone help me

the error is

NullReferenceException: Object reference not set to an instance of an object
ActivationBehaviour.OnMouseUp () (at Assets/HA.Unity-master/Scripts/Behaviours/ActivationBehaviour.cs:71)
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32)

Hi Guys, I would like to create the 3D scene like yours in my HA instance. Do you have a Tutorial or a workflow for that. I mean once unity is installed and my 3D scene created. How can i connect it to HA ? How to create the UI in Ha ?

Thanks in advance