Yio Remote Community

Poll: Node-RED for multi-device interactions?

Hello YIO community,

We have been discussing support for scenes / recipes within the team and on Discord for a while. Oh, and we need to find an official name for that feature too :wink:
Single device control is working pretty good in my opinion, now it’s getting time for the next step!
With our limited development capacity we are looking for an efficient way to control multiple devices, e.g. getting the home cinema ready with a single click. So, developing an all-inclusive controller for “every” possible device, including a usable UI is out of the picture, I guess. This could easily explode into a multi man-year project and you would have to wait a long time for features, only to find out, that a particular device is not supported.

Since this is a community project, we should take a community approach. It should be simple enough for non programmers to still contribute stuff and make changes, and of course share and improve work of others.

Here comes Node-RED into the picture!

I’ve shunned Node-RED for a long time, because I thought it’s just a “Raspberry Pi play thingy”. But the more I get to know it, the more I believe it’s the perfect tool for wiring together individual devices within YIO!
Next step is a proof of concept and measuring the resource consumption of the Node-RED process. I’m quite optimistic, that it will work well. Node.js is highly optimized and works very well on ARM devices.

What do you think?

  • Sounds good
  • Exactly what I have been waiting for
  • How can I help?
  • Bad idea. Please explain why with a reply
  • I have a better idea. Please let us know!

0 voters

I know node red and I understand that nodered is really powerfull and versatile.
but it seems like a potential overkill ?
and more importantly, i would be worry for the resource and the battery life, i’m pretty sure it will suck the battery like crazy.
Can you develop on why you think it could be a good solution ?
also we can already run nodered in home assistant (or anywhere else for the one who are not lucky enough to get home assistant :slight_smile: )
so the rest call should be enough
or if it’s just to trigger a bunch of action in a single press, maybe just that is enough (a shortcut for a list of action)

I haven’t been using NodeRed (although I instelled it earlier into my Home Assistant setup), but if this would mean that we could also map those physical remote buttons to whatever entities we have in Home Assistant, and based on selected activity as well (meaning that sometimes arrow buttons control TV, sometimes blu-ray player etc), then it sounds great :slight_smile:

The resource usage is a valid concern. Especially if it’s going to be abused with all kind of functionality, bad coding and external communications or polling.
My main intended usage on the remote is to provide an easy to use “device & action hookup” (please help me find a better name for it!) of already available entities and actions. It should mainly just communicate with the remote-software over websockets.
For this use case the resource usage seems to be pretty low. I have Node-RED running on the remote for two days now and the initial findings are:

  • Startup is kinda slow (~ 45s with one simple flow, Node version: 10.16.3)
  • Once running the CPU usage stays almost at 0% when idle
  • Sending one websocket command / sec to the YIO API: 1-3% CPU usage of Node-RED
  • Memory usage with one simple flow: ~ 45 MB
    Overall memory usage of all processes on the remote with Node-RED running: 95 MB (with 147 MB buffer/cache).

Developing integrations with Node-RED is certainly possible, but not recommended for running on the remote itself, especially if it involves polling or processing large messages.
If we enhance the YIO websocket API in a way the current Qt integration interface works, then everyone has the choice of running lightweight stuff directly on the remote or running a dedicated Node-RED instance for everything else.

That’s the tricky part, how to design the YIO API and UI: allow injecting UI elements or templates? Only expose defined entities with some kind of virtual remote entities? Create a simple UI designer?
Well, that’s something which needs some more thinking and experimentation together with @marton.

If an entity is defined in HA, then it’s usually also available in YIO. With an enhanced API even the unassigned entities could be addressed. That also needs some more investigation.

My first proof of concept is to access all entities and do some basic interactions within Node-RED.

I have always thought YIO as the ultimate one-remote-for-all -solution. Meaning that it could do everything that Harmony remotes (and similiar) can do, but also much more. Well, maybe it someday can, but at the moment (for me at least) it only can turn on and off Home Assistant switches, I have no idea how to use those physical buttons. I have seen somewhere those buttons being used, but then they sent IR commands directly, and I would like to avoid that after I found out that IR blasting has quite small range. So, I would rather use connection to my Home Assistant instead and let that do the needed tricks.

I can now control my devices using HA, and this is done pretty basic way, using HA and Logitech Harmony Hub that actually sends commands in addition to HA. So, in HA UI I have for example this:
image
Then, each button card sends commands to device, like this:

  - icon: 'mdi:arrow-up'
    tap_action:
      action: call-service
      service: remote.send_command
      service_data:
        command: DirectionUp
        device: 70846120
        entity_id: remote.harmony_hubi

The great thing is, that I can add whatever commands to one button card I want, and sequences as well. For example, I also switch sonoff S20’s on a second before harmony sends commands (I can use delays etc). But naturally, instead of pressing those button cards on Home Assistant UI, I would like to press remote buttons :slight_smile: But the problem is that those “buttons” are not actually entities on Home Assistant.

How about “activity” / “activities” ? That’s what Harmony calls them. Their solution is also quite perfect, as you can define which devices are in use in each activity, and you can also define which devices control volume and basically with each button, which device is the command send to. Then, you can also choose just to control each device independently, in that mode your remote becomes that device’s remote.

Anyway, I don’t know if Node Red is the solution (I have the add-on installed to my Home Assistant but never actually used it so I don’t know), but for me, in the end it doesn’t matter much what is “under the hood”, as long as eventually I can control my devices with YIO remote and “spice” things with Home Assistant as well :slight_smile:

2 Likes

I think someone posted PR about adding a device key to the commands, so the hardware buttons can be configured to send commands to the Home Assistant remote entity.

2 Likes

That looks promising, thanks for the link @marton! Although some kind of guide would be needed about how to map those buttons, the names of all YIO buttons etc… As if I have understood right, we cannot do this via web config yet…

My point why is it not the right way first to integrate all house automation systems like openhab and so on completely because most people here has one running on an external pi. And all scene are already programmed there and than its simple to activate the scene in the automation systems. Why doing again another flow programming? I know that it might be cool to have it some but the power usage is not the optimum of the remote by draining the battery now within of 11h and i have a 3000mAh battery inside.

First step should be the basic stuff for advanced stuff ist after that enough time, my opinion

I think there’s an example in the PR about the config. Unfortunately it’s not via web config yet.

The battery fuel gauge is fixed to 2500mAh, so if you want to fully utilize the 3000mAh one, you need to change the code and compile it.

I don’t think node-red would be used to create integrations. As @zehnm writes, more to create scenes if you’d also like to use the IR functionality of the dock.

Ahhhh good to know where do I need to change this? And could this also handled via a parameter in the settings? @marton

You can change it here:

Then need to cross-compile it and upload the binary to the remote.

It’s not possible to change it from config.json. Feel free to create a PR for it.

But it could be in the future??? @marton

It could, but it needs to be coded.

Cool thanks opened a PR

1 Like

I use Node Red for some of my Home Automations, I run it in docker alongside Home Assistant and a few others, (Not on a raspberry pi. :wink: )

Hi zehnm,

I think Node-RED is way to powerfull and complex to realize scenes / recipes on the remote.

I have a way simpler idea/suggestion:
A scene is an ordered list of actions. That’s it. When you start the scene the remote executes each action one by one. We will need a build-in action “delay/sleep”, so we can turn on the TV, wait 5 seconds and switch the channel.

If you need a more complex scene, then you should use Home Assistant/Openhab to setup the action and use it via the integration in the remote. You could use this action in a scene, too.

2 Likes

I fully agree with WilliTheSmith

There should something like a simple script language for example
1.do this
2. do this

Like the Harmony or the neeo does

As well as with other polling services these should be completely banned from the remote and may realized in the brain. There are planty of samples usi the esp32 as hue bridge and only if an action was done notified another point or directly using openhab