Accesing/setting another App variable

Hi everyone, I searched the docs and I haven’t found the way (it there’s any) to set another app variable. I’ve read about self.config["my_app][“variable”] , but I don’t know how to write on in from another app.
Is there a way?

Thanks!!

i dont know if that is directly possible.
i would probably write the value in a small file from app 1 and read the value out of the file from app 2.

You can add another app like this: self.AppLights = self.get_app("Lights")

You can then call functions to set parameters like this: self.AppLights.control("change", self.lights, brightness = 30, transition = 2). There is no magic, only logic, which you bring yourself :slight_smile:

There is also a global dict you can add values to but then you have to notify the other app in some way that it has been updated, or poll the dict for specific variables.

/R

thx, robban.
i actually never new if get_app would create a new instance or that it would be the same instance running that you can manipulate. (i never have used it anyway)
but it doesnt run the init again if you call it from another app, so obviously you can manipulate vars set in the init.

i forgot about the global dict :wink:

1 Like

Thanks to both of you!
I’ll try the write-to-a-file way first, and if not succeed will try the Robban’s way.

Cheers

1 Like

We do stuff differently rene. And that’s a good thing :smiley:

1 Like

most of the time i am so creative, because of lack of experience.
and because of that i always want to reach my goal, i come to solutions that people with experience dont think about. :wink:

I’m not entirely convinced this is necessary yet. Can you give an example of what you’re trying to achieve? I’ll work it out once I get home tonight

This isn’t clear to me what you’re trying to do yet. An example would greatly help me understand.

I have a motion sensor on my kitchen, that fires a timer to turn on the lights when I enter. The kitchen is small, so the motion sensor is constantly triggering, so I had a variable (self.active = true) to keep the automation from triggering a lot. Then when the timer finishes, it sets the variable to false. But from another automation (my plex plays, so I dim the lights on the living room and the kitchen. If I enter again in the kitchen while the timer keeps runing from the first automation, the lights doesn’t turn on again, because they’re still waiting for the timer to stop.
I know it’s a bit complicated, but my house distribution made me use that kind of automations.
That’s the reason I want to change the variable from the Plex light dim automation/app.

PS: Sorry for my english If I made a mistake :sweat_smile:

Robban’s way was they way I intended this to work, but files could work too :slight_smile:

1 Like

I do it by the rules, it’s the crazy ones like @ReneTode that go their own way that excell. :laughing:

2 Likes