 My name is Maya. I can say that I'm passionate about home automation probably because I worked in home automation sometime for a while. I also have a sort of smart home and most of all I believe that we can improve home automation. And what you will see in the following slide is almost this. What are the problems I see in the home automation systems today? I'm trying to solve the problems I see in my way. And in the case you want, how you could use this my pet project that I'm trying to present you. And this entire talk is about a smart just on off, nothing else that on off lie, I mean, as rich. And this is my first question. Why do I buy as rich to put in my kitchen? So one reason is when I cook, my hands are dirty, outside it's dark and I don't want to switch on the button. My system should be smart enough to turn on the light automatically. But sometimes even though outside is dark, I need for some reason I don't want my light to stay turned on. And I want to be able to say to my system that it should leave the light turned off even though outside is dark. And in the very same way when it's bright outside, I always forget to turn off my light because I never, I didn't, I don't realize that the light is on. And I want my system to do it automatically. But again, sometimes maybe I'm working in the darkest corner of my kitchen and I want to tell my system, okay now, let the light turn it on, even though it's bright outside. And I want to be able to force my light to stay on. And another way to say what I'm saying is this. What I want is a state machine. It's a quite simple state machine. It has four states. And in this case we are managing six events. And I can explain a little maybe what's the, yeah. For example, what is this first event we are managing? I mean, my system thinks that it's a good moment for my light to be off. It receives a motion event. And it could be that it changes my light to off or on. It depends if it is dark outside or not. And maybe we can spend also one more minute on the forced events. We can go from into a forced event starting, yeah. We are, if my light is for the system is off, then I can force it on. And if my light is on, then I can force my system to an off state, to an off state. And one more thing could be how can we exit from a forced state? We can use again the same push button. So we are forcing it off if we are in a forced on. Sometimes I use also the events to exit a forced state. It really depends on the state machine you want for your device. And that said, my next question is how complex it is to find reuse for me such an obvious automation. And I try to answer the question using Home Assistant, which I think the most of you know, but for the one that don't know this project is nowadays I think the biggest open source project we have. And yes, so I'm looking something for Home Assistant. And this is the closest solution I was able to find. This is not written by me. I found it googling for a solution for my problem. So we now go through this code. It's not so long, but let me tell you something about this. First thing is here we are reacting to a trigger. And so we are managing an event, but we should guess which event we are managing. And probably this is a motion event. And we can guess this by reading the name of the devices which made the trigger. And when we have guessed that this is a motion event, the next thing is understand which will be the state of our light. And the state for our light will be a non-state, because we are calling a service that says turn on my light. Yeah, turn on my kitchen light. And then we are also saying that we wait for another kind of event. And again, is an event regarding the motion. This time is a no motion event. And in this case the final state for my lights will be a non-state, because we are calling a service which is light to enough. So in this script we are dealing with two events and two states for the lights. There is something more. This guy also has designed a forcedon state, some sort of forcedon state. And he used for do this an input Boolean. An input Boolean is a graphical, yeah is an entity in Home Assistant that you can use. And, okay, it named this entity kitchen light override. And when this kitchen light override is selected, then what we get is yeah, I want to, okay, we turn, yeah, okay, yeah. When the input Boolean is selected, then we turn off the automation we have seen before. So we don't care anymore about the motion. And we said to the, and also we say to the system, okay, turn on my kitchen lights. So we disable somehow all the logics behind the motions. And yeah, this is almost the same, but it's the default case. So when the input Boolean is not selected, what are the problems I see here? Yeah, I can summarize them here. I think that this automation is complex to be reused. It mixes together the states, the events and the triggers. I have already said that we need to guess which are the events we are reacting to. We need to somehow guess which are the states for our final light. And this is more visible when you have more scripts than take care of the same devices. And also another thing is in my mind, when I think to a forced on state or forced off state, I don't think to use another entity in a user interface or maybe another push button in your room. I mean, I have a push button that can control my light. I want to say to the system, okay, now I'm forcing you to behave in a different way with just that push button. And okay, one more thing here is not listed. All we have seen was dealing with just three events out of the six I need. This is another problem I see. We have this light automated and to the end user, the automated light looks like this. I mean, it's like any other non-automated light. I don't really think this is much useful. How can I tell if someone has forced my light or if it is just turned on because the system knows that it should be turned on? And if I want to force it, you probably can see me that I can put here near this widget, the other widget, the input Boolean widget, but if I am the one that has written the script, probably I can understand it. Otherwise, maybe that's not the case. And it's not just a matter of widget. It's, I think, much more a matter of models. And I try to explain to you what I mean with this slide. Here we can see the history of our light. Here, sorry, it's in Italian, but the first row, it means turn it on. The second row, turn it off. The third row, turn it on. And the last one, turn it off again. And I wonder if someone finds this useful, really useful. I mean, I never look at this kind of history because, okay, I can say that my light has been turned on for a while. Maybe I can say it's more than I need. But behind my light, there is much more, I think. I want to be able to see, yeah, all the other events that can make change this light. So for me, this model, this just on off model, is not helping you and the others in your home understand what is going on. And I think this is the cause. This is taken from the Home Assistant website. And I think the really interesting sentence is the first one. I mean, yeah, this one. Home Automation itself has never been a goal of Home Assistant. And I think that the point is this. Home Assistant, as all the other Home Automation systems I know, are thought to be, to let you control your devices, not really to automate them. And if you remember in this slide we have seen before, there was a big focus on the voice control here. Because Home Assistant is putting a lot of effort in making you control your devices in just another way using your voice. And that's their goal. So you can say to me, but we have a rule engine in Home Assistant and we can use it. And that's true. But what I think is that this rule engine are designed to let everyone, almost everyone, create simple automation in a simple way. And to answer my own question, if I think there is enough automation in Home Automation, I think the answer is no. And I think that the reason is why we haven't derived tools for doing proper automation. I mean, complex automation. So in the second part, I would like to show you what I think could, what kind of solution I have almost working at my own. And yes, let me show you. So here are three switches, no more than switches. But you can see that the second one is not in an on or off state. It has another state, the forced state. And this is something that knows just the system, not the device itself, but for me that's enough. And near the state, there is the events it receives, and that makes the automation change. And you can also spot that there are different events. So this means these are all different automation for the very same kind of device. And this is again a history for the very same device as before in the same time. But this time we can see something more. We can see that the second time the light was not just on. It was forced on. And also we can see that for a while no one was there. And since it was forced on, the light stayed on since someone enforced it. And a few seconds later someone worked near the light and it turned on. But this time was the system to turn it on. I think that here we have some more information. And yeah, another thing I have, I can interact with the automation and create. And this is not really something that I use every day. I mean, this is just useful if you want to debug your connection. I mean, when you connect your automation with your devices or maybe when the system for some kind of reason goes out of sync, maybe it was just shut off for a while. So the system, okay, this is not something I need every day. But this instead is something I really use. And this is something that lets you change your automation accordingly with your needs. What I'm saying here to the system is stop managing the brightness event, behave like if outside is always bright. And in this way, this automation will end up not turning on my light again automatically because it's like there is always bright outside. Maybe this is not the best example. I probably use this feature more with other models like the blinds model or other kind of devices. But I think that be able to adjust the automation to your needs because your needs changes, it's something really useful. And to summarize it, which is the difference between this project and the other projects I know, the difference is that I write different abstract state machines for every automation I want. And this state machine became the model of different on-off lights, which are all the same device. In the other automation system, all the lights, all the same lights, always the same model. And yeah, one, yeah, now we can go through an example of how to use this project. So the first thing you need is to choose your automation, choose your model. So for example, I have put here two models, the kitchen model we have already discussed and another simple model like state machine I could use for an outdoor wall light. And after you have chosen your model, you can put it down. So you give it, you give them a name. And so they, so like this. And then what is missing is how to connect these abstract state machines to the real devices. And here I'm doing this. So my wall light, my outdoor wall light is a KNX device. So I'm saying here that this command is able to send an on command when the state for my abstract state machine is on or forced on. And it's also able to send an off command to this address, which is a KNX address. So no internet address, just something different. And yes, it's able to send also an off command when the state is forced off or off. In the same way, we need to send to the abstract state machine the events. We need to say which are the messages on the bus that trigger some event. So for example, messages to these multicast addresses can be mapped to a forced event on if the command inside the message is on. Otherwise, they can be mapped to forced off if the command inside the message is off. And in the same way, we can connect the kitchen light. In this case, I don't know which kind of device I have behind my kitchen light because I'm connecting to it using Home Assistant as a gateway. So I just know how to, which is its name for Home Assistant. And yeah, in this case, the commands can manage just or the on, in this case, or the turn off. So I need both of them to be able to manage the on, forced on, off, and forced off state. And in the same way we have done before, we need to map also the messages going through Home Assistant that triggers a forced on event and a forced off event. And after I have done this, I can put together my two lights. This will be used later. I need for the kitchen light to manage also the motion, no motion events, and here I am sending this kind of events to my state machine. So, oh, sorry. So, yeah, in this case, again, my motion sensor is a KNX device sensor. So I'm listening to a KNX address and I'm mapping this message to a, okay, an event that has this name, but maybe can be improved, but it's like motion event spotted. And in the same way, when we have no motion anymore. And this is quite simple. I think this is more complex. How can we deal with the brightness? I mean, it is simple if we want to just, yeah, I mean, the simple solution brings with it that if a cloud cross your sky, then the light will turn on, otherwise it will be turned off. And I don't want such cases. So I need an integration of the data for this. I need a scheduler. And this is why this example is a little bit more complex. So here I'm collecting the data that are coming from a sensor, again a KNX sensor, and the data of light. And I'm using these two triggers that says, okay, this is, yeah, sorry, this is greater than this value. If the collected data is greater than that value, then send to the state machine a brightness event. And this is saying if the collected data is lesser than this, then send to the state machine the dark event. And yeah, and we need to scheduler it to collect the data, analyze the data every 60 seconds into the scheduler. And we do this like in this example. So we are scheduling the triggers, which will send their events to our state machine through the performance. Sorry. So these are looks, I think. Yeah, you can, these triggers don't really know the value you put in. So you can put everything, but my sensor is measuring looks. So these are looks. And this is done. We have completely automated both the lights and all the events for all the lights. So for one light, six events, for the other light, four events. And probably you are wondering, what about building your own model? You need to be a developer because models are written in Python. And yeah, our state machine written in Python. But at least I think that they can be reusable. I try to make them understandable using PDT, testing them with PDT. And using PDT, you can then read their behavior. And yes, at least this. And yeah, which is the difference between so another, from another point of view, which is the difference between home assistant and this project. In home assistant, you have your physical device already modeled. And you write an automation around it. In this project, you write the automation. And then you tell to the system how to interact with your automation. How the physical devices can interact with your automation. And I know that this can seem boring. But I really like this feature because it really gives you a lot of freedom. I try to do just an example. I have these blinds. They are not out the door, are inside my room. But I have no sensor inside my room for detecting when my window are open. So, or I give up of using any kind of automation because it's too dangerous to close automatically the blinds when the window is open. Or I can have an automation, a complete automation, and just say to the automation that it can only turn up the blinds. And this is what I'm doing. I never connected the down command for my blinds in my automation because it's too dangerous. But the automation works perfectly with all the other states when it comes to move up the blinds. And yeah, here are the links related with some example for the project. And yeah, what's next? If you want, try it out. Let me know what do you think. And if you want, you can improve it. And yes. So, now, any questions? It's a state. And almost the triggers are all very much based on the motion thing, fire or not. So, I'm experimenting with setting the system where it basically has the primary thing is the state. Someone is in the room or the sun is up or something like that. And then having triggers sort of the information that can feed into that state. I'm not sure. I got you a bit. Okay. Yeah, so if you just have an higher motion detection, you can kind of assume, for instance, that there's been motion recently. So, what I do in mine, it's a non-binary thing. I'm old, so it's fuzzy logic instead of neural network, whatever. But it's basically, you know, there's a 100% chance of presence. And it goes down over, it stays over time. And then I can't have a threshold where it's like a big problem that was there. Because my wife did not like the lights going off on her occasion. Yeah. If I understand your problem, I don't like to turn off my light in the kitchen state machine. Yeah, sorry. Yeah, it's good. Okay.