Create a virtual Dimmer or light template for Alexa

Hi,

Sorry, I’m very new on this and trying to understand this codes.

so in configuration.yaml I have to do:

light:
  - platform: template
    lights:
      alexa_virtual:
        friendly_name: "Dummy light"
        turn_on:
            service: script.turn_on
            data:
            entity_id: script.dummy_ligh_on  
        turn_off:
            service: script.turn_off
            data:
            entity_id: script.dummy_ligh_off
        


emulated_hue:
  entities:
    light.dummy_light:
      name: "Dummy light"

If not, I don’t understand in what file the first part of the code has to go.

The part from emulated_hue I imagine that is inside configuration.yaml

The edit the call scrip, I imagine that other than to add this ligts, I have to create a script that has to turn on the device on, correct?

Sorry again, too new and never coded a lot.

Thanks in advance!

Baby steps :slight_smile:

What are you trying to do ?

hahahha, yes, thanks and sorry.

So as said in the other post, I have 2 Tuya door sensor that they are not accessed in Smart Life app from HA, and I’m unable to find their IP, as they connect only for 1 second when door opens and closes, so manual IP configuration for them it’s imposible. The workaround that I found is, as Alexa recognize it, is to have a smartplug to be turned on when the door is open. The issue of this system is that I have to have a smart plug (well, two as they are two sensors) only used of this.

The idea, to solve this issue, is to have a virtual small plug/light/other device that Alexa con turn on and so HA will recognize it. This is usefull for a Home Made alarm system.

So following yout steps, I created a light, but of course I’m doing something bad, because the virtua light is not turning on and off and neither Alexa finds it. The current configuration is the one that I added in the previous post.
I have several Alexa, a Nest Mini and a Hue Bridge with some lights.

Thanks in advance for your help.

OK . small steps .First you have to get Emulated hue , or Nabu Casa working. see

You must able to get a device from HA to be recognised by Alexa , otherwise you have nothing to trigger.

Once you have a device from HA in Alexa . You can create a routine in Alexa that when the motion detector is activated you get alexa to trigger that HA device (switch, bulb , script , etc). That’s the idea for the virtual bulb its just a trigger for HA to react too.

Your trying to do everything in one step

Hi,

Thanks for this links. I managed to create following the instructions the virtual light, but I have 2 problems now with it.

Problem 1: It duplicated all the lights, don’t know if you know a way to undo this and only to have the new lights.
Problem 2: HA and Alexa are unable to turn on and off the light created that I named “Alexa Luz Sim Entrada”. Here I think the issue is #Luz Falsa# that script “script.theater_lights_on” doesn’t exist in my HA, but when creating it, I don’t know what to do with or activate.

If you can help, (another time) I really apreciate it a lot.

This is the code that I used:

#### Fake Hue ###

emulated_hue:
  listen_port: 80
  off_maps_to_on_domains:
    - script
    - scene
  expose_by_default: true
  exposed_domains:
    - light
  entities:
    light.sensor_entrada_light:
      name: "Alexa Luz Sim Entrada"

#### En Fake Hue ####

#Luz Falsa#

light:
  - platform: template
    lights:
      theater_lights:
        friendly_name: "Alexa Luz Sim Entrada"
        turn_on:
          service: script.theater_lights_on
        turn_off:
          service: script.theater_lights_off
        
#End Luz Falsa

I think you have exposed all the lights to Alexa.

Remove

expose_by_default: true
exposed_domains:
- light

Then login into Alexa via the web and forget all and redicover

If the light scripts are not working In HA, then you will need to raise another thread , I dont think you need a virtual bulb :slight_smile:

Hi,

Thanks again for the reply. So I’ll remove that and manually delete it.

The script " script.theater_lights_on" I have not created anything, only added that commanad. You think that a script inside HA with the same name has to be created?

If not, I’ll raise a thread with it. Thanks again (a 1000) for your help!

Regards,

Hi solved!

If I removed the "expose_by_default: true" it will cause that all the devices are detected. So I keep it. Manually I can remove the other devices, but they do not disturb right now, also if they are duplicated. The expose to false maybe I can do it once I want to add more lights or things to HUE, or if removing the rest and doing a future manual check.

To solve the issue with the light on/off I removed the script part and is working, so I left it as:

light:
  - platform: template
    lights:
      theater_lights:
        friendly_name: "Alexa Sensor Sim Entrada"
        turn_on:
        turn_off:

With the Alexa automatio now what I wanted is working perfectly (other that the 20 extra devices :smiley: )

Thanks again and have a nice day!

Regards,

1 Like

Hi all,

Just had another issue after one of the last updates, and the turn_on and turn_off gives an error “Inccorct type. Expected “object””. But I’m unable how to solve it.

light:
  - platform: template
    lights:
      theater_lights:
        friendly_name: "Alexa Sensor Sim Entrada"
        turn_on: *Here is the error code*
        turn_off: *Here is the error code*

Any ideas?

None of the dummy lights are working when updated to 2022.2(.3)

Any idea?

Thanks

no issue here running 2022.2(.3). Works fine

 - platform: template
    lights:
      alexa_virtual:
        friendly_name: "Dummy Light"
        turn_on:

        turn_off:

        set_level:

So the problem could be at automatizations. I have some like this:

alias: Comedor noche
description: ''
trigger:
  - platform: state
    entity_id: light.alexa_virtual_comedor_noche
    from: 'off'
    to: 'on'
action:
  - type: turn_on
    device_id: c0ac2667d9e04af6890b4dd503d9bb15
    entity_id: switch.koogeek_o1eu_1fe326_3
    domain: switch
  - service: light.turn_off
    target:
      entity_id: light.alexa_virtual_comedor_noche
    data: {}
mode: single

And at configuration.yaml:

      alexa_virtual_comedor_noche:
        friendly_name: "Alexa Dummy Comedor Noche"
        turn_on:
        turn_off:
        set_level:

confirm the bulb works within the alexa app . If you turn the bulb on and off in the alexa app . Is this reflected in HA ?

Solved. The issue was that there is a condition that execute or not the automation if any person is ‘at home’. This variable always returned away, so the automation was running fine, because for HA nobody was at home.

Thanks

Thank you sir. You saved my day.

1 Like

hm… having one entity with a level from 0 to 100 - so I need to always remember which value has been linkt with which action / routine / etc.?

I don’t know… that doesn’t really sound “smart” to me…

Because if that I decided to use input_booleans instead with corresponding names, e.g. input_boolean.safety_check or input_boolean.temperature and so on.

There is no wrong solution as long as it works . I Sometime use the Alexa app on my phone when Im away , so only having 1 entity exposed from HA keeps thing much neater . I had 12 scripts and three input_booleans in Alexa all with unique names so I could call them correctly . Now I have Alexa routines which set the virtual bulb and I one automation in my case NodeRed which call the correct subflow and then reset the bulb.

hm… ah yes. Sure. You can work around the amount of entities by creating routines in alexa… That’s right. Haven’t thought about that option :smiley:

see

This show how you leverage the Alexa routines with virtual bulbs

I’m currently rewriting this in Nodered which is a much simpler solution to maintain