Hi! Time to get rid of the HC2 and installing the new homey 2023.
I have an old script that i got thats control if a person is leaving the apartment. (Have been good to have if friends is borrowing the apartment or a neighbour is watering the plants ) I´ll have that when the door is opening i run a flow that are lightning up the apartment and this script is what i have for shut down everything when they leave.
Tried to remake it in Advance flow but i got stop at the first step trying to save time the door was open to a variable.
I guess it maybe need to be done in HomeScript but i don´t understand that. (have a little bit of understanding a script and copy paste to change simpler things but thats it)
So now i have a big question of help if there is a kind soul that feel this sounds like a good Flow to have and wants to translate it to a working Homey flow
Regards
Christian
TEMP
--[[
%% properties
438 value
20 value
146 value
233 value
%% globals
AwayState
PresentState
--]]
-- 438 is sensor door
-- 20 is sensor movement in hallway
-- 233 is sensor movement in bedroom
-- 146 is sensor movement in kitchen
-- Kill any extra instances of the same scene
if (fibaro:countScenes() > 1) then fibaro:abort() end
-- Get modification times
door = fibaro:getValue(438, "value")
door_time = fibaro:getModificationTime(438, "value")
motion = fibaro:getValue(20, "value")
motion_time = fibaro:getModificationTime(20, "value")
local hall_lastModified = fibaro:getModificationTime(20, 'value')
local kitch_lastModified = fibaro:getModificationTime(146, 'value')
local sov_lastModified = fibaro:getModificationTime(233, 'value')
if tonumber(door) == 1 and tonumber(motion_time) < tonumber(door_time) and fibaro:getGlobalValue("AwayState") ~= "AtHome"
then
if tonumber(motion) == 1
then
fibaro:debug(”On my way out”)
fibaro:debug("-------")
fibaro:debug(”wait 5 min")
fibaro:setGlobal("PresentState", "Door")
fibaro:sleep(5*60000) -- Wait 5 min sleep
fibaro:debug("5 min has passed)
fibaro:debug("-------")
-- Registry latest movement
local hall_lastModified = fibaro:getModificationTime(20, 'value')
fibaro:debug("Hall ModificationTime: "..os.date("%c", hall_lastModified))
local kitch_lastModified = fibaro:getModificationTime(146, 'value')
fibaro:debug("Kök ModificationTime: "..os.date("%c", kitch_lastModified))
local sov_lastModified = fibaro:getModificationTime(233, 'value')
fibaro:debug("Sovrum ModificationTime: "..os.date("%c", sov_lastModified))
fibaro:debug("-------")
if
((os.time() - hall_lastModified) >= 240) and -- No motion detected for 4 min
((os.time() - kitch_lastModified) >= 240) and -- No motion detected for 4 min
((os.time() - sov_lastModified) >= 240) -- No motion detected for 4 min
then
-- If the scene has been triggered and there is no movement in the sensors, we come here
fibaro:killScenes(296)
fibaro:sleep(1*10000) -- Wait 10 sec
fibaro:setGlobal("PresentState", "Away")
fibaro:startScene(19) -- All off
fibaro:call(394, "sendDefinedPushNotification", "187") -- send push info
fibaro:debug(”Have went out)
fibaro:debug("------")
else
-- If the scene has been triggered and there is movement in one of the sensors, we come here
fibaro:setGlobal("PresentState", "Home")
fibaro:debug(”Movement - is still home")
fibaro:debug("------")
end
else
fibaro:debug(”On ”my way in)
fibaro:setGlobal("PresentState", "Home")
fibaro:debug("-------")
end
end```
The scenario :
– Me and my girlfriend are not in the city. Two friends is borrowing the apartment and are not connected to homey.
– I have a scene that if its dark and the two friends is coming home and opening the front door. The lights is turned on and a variable is change from “away” to “home”.
Now to the scene that i want to have. (Its a home or away scene if a person isn’t connected to homey)
My friends is opening the front door and leaving the apartment. Then I want to run the scen ”leaving the apartment” (lights goes out and a variable gets “away”) (in the old script we used the trigger of motion in hallway first and then door sensor trigger to start the scen)
But then the person maybe just open the door to let somebody in or going out with the garbage, or just one person is still home watching TV. Then i don’t won’t the ”leaving the apartment” scen to kick in. (Kill the ”leaving the apartment”-scene if movement in any of the motion sensors within 5 minutes)
But then there is another problem I have hade with people in the apartment when we are not home. (Haven’t got that to work with the old fibaro scene.)
It is when my neighbor across is watering our plants when we are gone. Then he is opening the door – the coming home scene is kicked in (lights on and variable gets “home”). But he never close the front door. Leaves it open, watering the plants, leave and close the front door. Then i got an apartment that are all light up and a variable saying home.
You’re welcome! I own a Pro 2019, and the test import went well.
My guess is the Pro 2023 handles the script slightly different. I’ll check with the app developer @Arie_J_Godschalk.
Arie, can you import this flow for me on the Pro 23 to see what goes wrong?
I got an idea as workaround, I replaced the sun cards for fixed time cards and made a new export.
When it works, you can replace the time trigger cards for the sun rise/set cards yourself afterwards.
Yeah, i get the same error, looks like something changed with the Sunrise card?
Yeah, it looks like the Sunrise card is different:
I dont even have that one on HP2023 anymore, it has been changed to:
The Sun rises in [number of] minutes.
So, use that one and set it to 0 minutes?
I have created a ticket (slack message) to check if this is on purpose (might very well be) or a bug.
If on purpose, just don’t use this card for now
Sorry, thats not the correct card.
That card is gone in HP2023, they changed the other card to include an extra number field…
So, no real nice way of fixing this.
Let’s wait on the anwser by @Emile on slack, then i’ll know if and how to solve this.
Hmmm Emile says these sun cards are incompatible with Pro23, when you copy a flow with TFE if I’m right.
The Athom migration tool (should) converts them somehow.
Arie, maybe you can create dummy cards for those sun cards, like you did for the Homey script cards?
Then the script would run OK and
the user only has to replace those dummy cards after the import.
Euhm, yeah, or i just replace the faulty cards with the correct new card
It’s the same amount of work.
Just have to check the import from new to old aswell.
i couldend import the scrips so i have maked a new flow from the pictures. But i don´t understand witch logic card i should use. Its an “and” card from logic i guess? This is the closest a could find. is that correct?