I have a switch.yaml with the following content. But the third switch won’t show “TendaP3”. I can delete “TendaP2” and P3 will show.
It just seems that if I add more than 3 switches the last ones are ignored. I have tried reformatting in various ways and nothing seems to work. I’m guessing it’s a really simple mistake but I can’t seem to spot it.
Adding 3 doesn’t show it and the switch isn’t showing in developer tools => states at all.
There seems to be something odd going on as it just showed all 4 (I hadn’t changed the yaml). I then made a backup of my switches.yaml. After that I edited switches.yaml again and it went back to showing only 3 again. I restored the previously working backup and it’s still showing just 3 switches which makes no sense at all.
I have tried restarting HA and just reloading yaml but it’s still not working. I’m wondering if my HA install is messed up somehow. Or if it’s something in the core.entity_registry but I don’t want to break everything or start from scratch really.
I have just gone through and rewritten the code to make sure there are no tabs, same result, HA just sees the first 3 rest switches. I also tried a clean virtualbox install of HA with the same results. It’s very strange, has anyone else got an example using more than 3 rest switches that is known to work? I’d like to compare it to see if I’m doing something different.
Well I have managed to use command line switches as a workaround. I need to figure out how to check the plug status of individual sockets, but that’s a task for another day.
I’ll paste the code below for anyone else using a Tenda SP15 power strip.
If anyone can figure out why the rest version doesn’t work please let me know.
Hi Daniel, wondering if you’ve made any progress with this. I’m running into the same problem. Only 3 switches come up. It’s also not just a gui issue as the other two switches aren’t in the list of entities on the developer-tools/state page.
Show your config. The format for command_line has changed since that last post: see about halfway down this page (can’t link directly due to duplicate anchors in the page):
EDIT: I just went back to HA and noticed that they’re all there now. Only changes I can think of is that since adding the switch to HA, I powered it off for a couple of days and I completely shut down HA (previously just restarted via the UI). Perhaps either of those helped? I’ll leave the original post below in case it helps others.
Thanks for the reply Troon and Daniel.
Here is the entry from my configuration.yaml. I haven’t gone the command line route yet as I was trying to keep things ‘simple’.
The below code works for me with the only issue being that only the first 3 entries are loaded. So with the example below, TendaUSB and TendaAll aren’t loaded. Is going the command line route the only option?
HA version are below:
Home Assistant 2022.8.7
Supervisor 2023.06.4
Operating System 8.5
Frontend 20220802.0 - latest
If you reset the “REST ENTITIES AND NOTIFY SERVICES” via the developer tools, it will revert back to the the first 3 REST entries (I imagine the same will happen if you restart HA). In order to get it to load properly, I found that I needed to reset the powerboard and while it’s reconnecting to wifi, clicked on the “REST ENTITIES AND NOTIFY SERVICES” via the developer tools. This loaded all of the entities.
The issue I’m having now is getting the status to work properly. I think the below code refers to the status of the main power switch which turns all of the switches off/on.
So if one switch is on, all of the socket status will be set to on regardless of real world status. So switching the device off via HA results in the switch status turning off for a brief moment before changing back to on.
Using action instead of status (see below) results in the opposite, all devices are seen as off regardless of real world status.
I also tried Daniel’s code (see below), but this resulted in the off/on toggle turning into two lightning bolts. One for off, one for on and no status.
is_on_template: "{{ value_json.data.subdevice.dev_name == PLUG1 and value_json.data.subdevice.status == 1 }}"
Any ideas, should I give up trying to get it to just work via the REST entries?
Hope this helps others. Still no progress on only having the first 3 rest entries being loaded if you restart HA or reload the rest entities via the developers page.
That’s great work, I was struggling to get the subdevice status working.
I am just using the command line configuration currently as it seems to be less buggy and temperamental than just using REST.
Thanks for the links too, I’ll add those to my bookmarks, I spent many hours searching for good resources about this and just ended up even more confused.
I took the leap and deleted my command line switches and everything now works under REST! I’m still not sure if the problem was something specific with this Tenda power strip, or if there was an update in Home Assistant that fixed things.
Thanks maud for figuring out how to get the subdevice status and pushing forward when I had given up.