hass-virtual icon indicating copy to clipboard operation
hass-virtual copied to clipboard

Need help! No device or entities are generated

Open christic73 opened this issue 10 months ago • 16 comments

versions:

  • virtual components: 0.9.1
  • HA 2025.1.4

Hi,

I followed the instructions mentions in the readme:

I created a simple test yaml with two devices as of the readme:

version: 1
devices: 
 Living Room Sensor:
  - platform: binary_sensor
    name: Living Room Motion
    initial_value: 'off'
    class: motion
 Back Door Sensor:
  - platform: binary_sensor
    name: Back Door
    initial_value: 'off'
    class: door

I named the file virtual_cover.yaml and stored it here /homeassistant/virtual/virtual_cover.yaml

Then ...

  • I installed virtual from HACS
  • I restarted
  • I went to Settings -> Devices and Services -> + ADD INTEGRATION
  • I searched for Virtual and selected Virtual Components
  • I chose the name imported and pointed it at my file /homeassistant/virtual/virtual_cover.yaml

After hitting OK, I received a success message. Image

However, there is no device generated. Image

What is it I'm doing wrongly?

christic73 avatar Jan 31 '25 16:01 christic73

It's look good here. One thing to try might be the indentation, try lining up the - with the line above. The code uses a standard YAML parser so it might be being too picky.

If that doesn't work turn on debug and send me the output. There might be a clue in that.

twrecked avatar Jan 31 '25 16:01 twrecked

hi twrecked,

thanks for the fast response!!! I tried it as you suggested, but no success. I also simplified the yaml with just 1 device instead of three, also no success.

here the log, I hope this helps.

2025-01-31 21:51:53.073 DEBUG (MainThread) [custom_components.virtual.config_flow] step user None 2025-01-31 21:52:04.340 DEBUG (MainThread) [custom_components.virtual.config_flow] step user {'group_name': 'imported2', 'file_name': '/homeassistant/virtual/virtual_device2.yaml'} 2025-01-31 21:52:04.340 DEBUG (MainThread) [custom_components.virtual.config_flow] checking imported 2025-01-31 21:52:04.342 DEBUG (MainThread) [custom_components.virtual] async setup {'group_name': 'imported2', 'file_name': '/homeassistant/virtual/virtual_device2.yaml'} 2025-01-31 21:52:04.342 DEBUG (MainThread) [custom_components.virtual] creating new cfg 2025-01-31 21:52:04.342 DEBUG (MainThread) [custom_components.virtual.cfg] _async_load_yaml1 file_name for /config/.storage/virtual.meta.json 2025-01-31 21:52:04.349 DEBUG (MainThread) [custom_components.virtual.cfg] _async_load_yaml3 file_name for /config/.storage/virtual.meta.json 2025-01-31 21:52:04.349 DEBUG (MainThread) [custom_components.virtual.cfg] _async_load_yaml1 file_name for /homeassistant/virtual/virtual_device2.yaml 2025-01-31 21:52:04.351 DEBUG (MainThread) [custom_components.virtual.cfg] _async_load_yaml3 file_name for /homeassistant/virtual/virtual_device2.yaml 2025-01-31 21:52:04.351 DEBUG (MainThread) [custom_components.virtual.cfg] loaded-meta-data={} 2025-01-31 21:52:04.351 DEBUG (MainThread) [custom_components.virtual.cfg] loaded-devices={} 2025-01-31 21:52:04.351 DEBUG (MainThread) [custom_components.virtual.cfg] meta-data={} 2025-01-31 21:52:04.352 DEBUG (MainThread) [custom_components.virtual.cfg] devices=[] 2025-01-31 21:52:04.352 DEBUG (MainThread) [custom_components.virtual.cfg] entities={} 2025-01-31 21:52:04.352 DEBUG (MainThread) [custom_components.virtual.cfg] orphaned-entities={} 2025-01-31 21:52:04.352 DEBUG (MainThread) [custom_components.virtual] creating the devices 2025-01-31 21:52:05.353 DEBUG (MainThread) [custom_components.virtual] update hass data {'imported': {'entities': {}, 'devices': [], 'file_name': 'homeassistant/virtual/virtual_cover.yaml'}, 'imported2': {'entities': {}, 'devices': [], 'file_name': '/homeassistant/virtual/virtual_device2.yaml'}} 2025-01-31 21:52:05.354 DEBUG (MainThread) [custom_components.virtual] creating the entities 2025-01-31 21:52:05.354 DEBUG (MainThread) [custom_components.virtual.binary_sensor] setting up the entries... 2025-01-31 21:52:05.355 DEBUG (MainThread) [custom_components.virtual.binary_sensor] installing binary_service handlers 2025-01-31 21:52:05.356 DEBUG (MainThread) [custom_components.virtual.cover] setting up the entries... 2025-01-31 21:52:05.356 DEBUG (MainThread) [custom_components.virtual.device_tracker] setting up the device_tracker entries... 2025-01-31 21:52:05.356 DEBUG (MainThread) [custom_components.virtual.device_tracker] installing handlers 2025-01-31 21:52:05.357 DEBUG (MainThread) [custom_components.virtual.fan] setting up the entries... 2025-01-31 21:52:05.357 DEBUG (MainThread) [custom_components.virtual.light] setting up the entries... 2025-01-31 21:52:05.358 DEBUG (MainThread) [custom_components.virtual.lock] setting up the entries... 2025-01-31 21:52:05.358 DEBUG (MainThread) [custom_components.virtual.number] setting up the entries... 2025-01-31 21:52:05.359 DEBUG (MainThread) [custom_components.virtual.sensor] setting up the entries... 2025-01-31 21:52:05.360 DEBUG (MainThread) [custom_components.virtual.sensor] installing handlers 2025-01-31 21:52:05.362 DEBUG (MainThread) [custom_components.virtual.switch] setting up the entries... 2025-01-31 21:52:05.362 DEBUG (MainThread) [custom_components.virtual.valve] setting up the entries... 2025-01-31 21:52:05.363 DEBUG (MainThread) [custom_components.virtual] installing handlers

the yaml I used:

version: 1
devices: 
    Living Room Sensor:
    - platform: binary_sensor
    name: Living Room Motion
    initial_value: 'off'
    class: motion

christic73 avatar Jan 31 '25 21:01 christic73

Try setting the file name to /config/virtual/virtual_device2.yaml. The file location isn't the same inside the container.

I think the issue here is I forgot to add a "can't find the file" error.

twrecked avatar Jan 31 '25 21:01 twrecked

Yes, that's it. Thanks for your fast help. You are awesome ☺️

christic73 avatar Feb 01 '25 07:02 christic73

Maybe one more question. How would you generate a device for a Venetian blind with vertical cover and tilting elements?

christic73 avatar Feb 01 '25 07:02 christic73

I tried all of this and still have the same issue. What's the problem. I even enabled logging and it doesn't show a thing in logs. What do we have to add to the main config file for this to load.

Well I found the issue a lot of us is having. The issue is when we copy and paste from the site for the device we want. Its not pasted right, in fact its all left justified. I will show examples below with the lights.

This one is good:

version: 1
devices:
 Test Lights:
  - platform: light
    initial_value: 'on'
    support_brightness: true
    initial_brightness: 100
    support_color: true
    initial_color: [0,255]
    support_color_temp: true
    initial_color_temp: 255
    support_white_value: true
    initial_white_value: 240

This one is bad:

Test Lights:
- platform: light
  initial_value: 'on'
  support_brightness: true
  initial_brightness: 100
  support_color: true
  initial_color: [0,255]
  support_color_temp: true
  initial_color_temp: 255
  support_white_value: true
  initial_white_value: 240

Its a very minimal difference and can barely see it. There is a space at the beginning of the device name. 2 spaces at the - and then 4 spaces for each line following. In the bad it is NO space for the name, no space before - and 1 space for the following. So if you can't get it to work, add a space, then 2 spaces then 4 spaces and save the file. This time it will work. Just copy my example for the good and it will work, making sure to get the spaces too. I feel the creator should have posted his yaml the correct way and not let us in limbo to come here thinking we are the dumb ones. When infact it ain't us, its the creators fault. If this offends you, good, then you know you messed up and you learned from it. Thanks.

sdennis91 avatar Feb 23 '25 12:02 sdennis91

@sdennis91 feel free to send PR with improved Documentation, they were always welcomed.

Tony763 avatar Feb 23 '25 15:02 Tony763

Can you paste in the changes you make to enable logging?

Sorry for being brief I'm away from my computer this weekend

On Sun, Feb 23, 2025, 10:47 Antonín Skala @.***> wrote:

@sdennis91 https://github.com/sdennis91 feel free to send PR with improved Documentation, they were always welcomed.

— Reply to this email directly, view it on GitHub https://github.com/twrecked/hass-virtual/issues/153#issuecomment-2676933543, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALHJU6VXODLTZC2X767ZO732RHUR5AVCNFSM6AAAAABWH44BNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNZWHEZTGNJUGM . You are receiving this because you commented.Message ID: @.***> [image: Tony763]Tony763 left a comment (twrecked/hass-virtual#153) https://github.com/twrecked/hass-virtual/issues/153#issuecomment-2676933543

@sdennis91 https://github.com/sdennis91 feel free to send PR with improved Documentation, they were always welcomed.

— Reply to this email directly, view it on GitHub https://github.com/twrecked/hass-virtual/issues/153#issuecomment-2676933543, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALHJU6VXODLTZC2X767ZO732RHUR5AVCNFSM6AAAAABWH44BNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNZWHEZTGNJUGM . You are receiving this because you commented.Message ID: @.***>

twrecked avatar Feb 23 '25 17:02 twrecked

@sdennis91 feel free to send PR with improved Documentation, they were always welcomed.

I have included the improved code example in my post.

sdennis91 avatar Feb 24 '25 12:02 sdennis91

@sdennis91 Both your yaml examples work for me.

Can you include a link to the bad yaml and I'll fix it.

twrecked avatar Feb 24 '25 23:02 twrecked

@sdennis91 Both your yaml examples work for me.

Can you include a link to the bad yaml and I'll fix it.

Ok odd. Only one of my examples work for me. The first one works and the second one don't. Why is that. Every example I tried on the documentation of the add on don't work unless I add a extra space in front of the name and 3 spaces in front of the lines after the name. This might just be a bug where some setups it works with both examples and the ones on your page while other setups it needs the extra spaces. I'm running home assistant os on a raspberry pi 5 if that might make a difference. In the mean time I got things working on my end with the extra spaces.

sdennis91 avatar Feb 25 '25 11:02 sdennis91

What editor are you using?

twrecked avatar Feb 25 '25 12:02 twrecked

What editor are you using?

I'm using the file editor that is in the home assistant add-ons from the add-ons store.

sdennis91 avatar Feb 25 '25 14:02 sdennis91

I don't use an environment like that, maybe someone who does can chime in.

@sdennis91 But a quick FYI:

I feel the creator should have posted his yaml the correct way and not let us in limbo to come here thinking we are the dumb ones. When infact it ain't us, its the creators fault. If this offends you, good, then you know you messed up and you learned from it. Thanks.

Write anything this insulting and rude and stupid again and I will not bother helping you in the future. A quick bit of back ground:

  • I wrote this plugin for me and made it available in case other people find it useful.
  • I work on this plugin for free and I tackle issues and bugs in my spare time.
  • I'm not deliberately documenting things to make people feel dumb, under what circumstances does that make any sense at all? Seriously, think before you write.

So going forward, if you raise any issues I will be absolutely willing to help fix them, the fix may ultimately benefit all users of the plugin, but you need to change your attitude.

Do you understand?

twrecked avatar Feb 25 '25 15:02 twrecked

I don't use an environment like that, maybe someone who does can chime in.

@sdennis91 But a quick FYI:

I feel the creator should have posted his yaml the correct way and not let us in limbo to come here thinking we are the dumb ones. When infact it ain't us, its the creators fault. If this offends you, good, then you know you messed up and you learned from it. Thanks.

Write anything this insulting and rude and stupid again and I will not bother helping you in the future. A quick bit of back ground:

  • I wrote this plugin for me and made it available in case other people find it useful.
  • I work on this plugin for free and I tackle issues and bugs in my spare time.
  • I'm not deliberately documenting things to make people feel dumb, under what circumstances does that make any sense at all? Seriously, think before you write.

So going forward, if you raise any issues I will be absolutely willing to help fix them, the fix may ultimately benefit all users of the plugin, but you need to change your attitude.

Do you understand?

O ok. Sorry about that. Some times you have to be a bit cautious at first, these days online. 25 years ago the internet wasn't filled with people who would write code to take over a persons pc. They started using code to fool people in vista and 7 when the sidebar was a thing. Hence the sidebar was removed in a update and no longer carried over to windows when 8 came out. Again im sorry. Im glad your able to help, as this seems to be an issue not just on my end but others as well. Prolly more then we know. Some may have tried it and it didn't work so they removed virtual devices. I did find it very useful, now that I got it working by adding spaces. Anyways what do you use to write the yaml code. It might be easier for the both of us to track down issues that may arise in a update. As I could download what you use and compare it to file editor on home assistant os. This would also allow me to help people who use file editor by converting the yaml over to file editors layout. I just wonder if the creator of file editor knows of such a bug or if this is the design. As I found the spaces are needed in file editor. I understand where your coming from.

sdennis91 avatar Feb 25 '25 16:02 sdennis91

Apology accepted.

I'll try and set up a home assistant OS over here, I think I can spin up a VM with it on. I'm currently using it on docker and editing files directly with vi. It'll be a day or two to get stuff running so I'm glad you get it working for now.

It does seem like there is something odd happening and I'd like to figure out what it is. Then I can update the docs and nobody else has to deal with this.

twrecked avatar Feb 25 '25 16:02 twrecked