CoRE and Piston Rules Engine, first design steps

Do you think with this tool, you’ll ever need to start over with your whole system? I think rebuilding one of these pistons will give you that adrenaline rush…You’re hub is grateful for @ady624 s work. He’ll finally take a break from being stripped down…:slight_smile:

1 Like

But I don’t want to disable the piston, only parts of the piston, at different times.

I’ve also got it working now using a simple piston.

I’m going to write out the entire logic flow with all events and scenarios… That’s a book, give me a minute.

2 Likes

I’m building this piston using a modular thought process. Then I can make changes, remove, add, modify, without having to rebuild the entire thing.

2 Likes

That’s the way to go! And an excellent way of testing CoRE. Hats off to you for the effort…

2 Likes

I just tested this out.

[CODE]
IF
Time is between sunset and sunrise
AND
Front Door Contact is one of [open, closed]
AND
Back Door Contact is one of [open, closed]
AND
Back Garage Door is one of [open, closed]

THEN
Using Front Door
Set Level to 50%
Turn on
Using Back Door
Set level to 20%
Turn on

THEN IF
Front Door Contact is open
>>>when true>>>
Using Front Door
Set level to 100%
OR
Front Door Contact is closed
>>>when true>>>
Using Front Door
Set level to 50%
OR
Back Door Contact is open
>>>when true>>>
Using Back Door
Set level to 100%
OR
Back Door Contact is closed
>>>when true>>>
Using Back Door
Set level to 20%
OR
Back Garage Door Contact is open
>>>when true>>>
Using Outside Back Garage
Turn on
OR
Back Garage Door Contact is closed
>>>when true>>>
Using Outside Back Garage
Turn off

THEN
(leave empty)

ELSE
Using Front Door and Back Door
Turn off
[/CODE]

Everything works as expected expect for

[CODE]
Front Door Contact is open
>>>when true>>>
Using Front Door
Set level to 100%

Back Door Contact is open
        >>>when true>>> 
          Using Back Door
            Set level to 100%

[/CODE]

If I manually set those lights to 100%, while the doors are open, then close them they will dim back to their specified value, but if they are at the dimmed values and I open the door they do not go to 100%. I have another condition for back garage door that’s just a simple on/off switch. It works correctly on open and close. Not sure why to two conditional to set lights to 100% when doors opened do not work? I also have no other smartapps associated with the contacts or lights of for those.

1 Like

You have overcomplicated it a bit. Remove the THEN statement actions:

THEN
    Using Front Door
        Set Level to 50%
        Turn on
    Using Back Door
       Set level to 20%
       Turn on

When the IF statement is true, the THEN above runs, then the THEN IF below it is evaluated and actions are again started. You’re basically asking the front door to go to 50% then immediately go to 100 (if door open) or 50 (if door closed). You have a race condition on which of the two commands wins. Leave it to just IF (condition) THEN IF (conditions with individual actions) and you should be fine.

1 Like

v0.0.043.20160525 - Alpha test version - Fixed toggle virtual command, modified the Flash virtual command to turn the switch back on if it started on, added the Cancel Pending Tasks virtual command, added action advanced options Task Override Scope and Task Cancellation Policy. Global scope does not yet work, CoRE would have to “spread the word” to all child pistons. Improved the device condition evaluation to speed up things - took common code outside of the device loop.

Also: fixed the button reevaluation to false. Buttons don’t change states, so that complicates things on subsequent evaluations. If you have a condition on button is pushed OR door is open, if you push the button and then open the door, on both evaluations button is pushed would be true, because the button’s state is still… pushed. Should be fixed now.

3 Likes

Yep…do that too! :slight_smile:

2 Likes

I think it did execute, although I had some older rule machine automation going on also. I will stop all other rule automation and check that it is working. Thanks!

1 Like

v0.0.044.20160525 - Alpha test version - Fixed the command description for custom commands - temporary until custom commands are complete

Can you please confirm the name is okay now? Though it will not show parameters or anything, but at least it won’t say [ERROR] until I finish up with the custom commands…

1 Like

Is it safe to say that pistons built so far won’t need to be removed with future releases?

@ady624

I finally played around a bit with the HSL values pertaining to the four White color tones. I used values based on an earlier post by @blong (post #947)

Note below that I only adjusted the “h” and “s” values. The “rgb” and “l” values I left as you currently have it in your code.

These values work well for Hue lights when selecting by color: Soft White, Warm White, Daylight White and Cool White.

    [ name: "Soft White",				rgb: "#FFA757",		h: 23,		s: 56,		l: 67,		],
    [ name: "Warm White",				rgb: "#FFB16E",		h: 20,		s: 80,		l: 72,		],
    [ name: "Daylight White",			rgb: "#FFE4CE",		h: 53,		s: 91,		l: 90,		],
    [ name: "Cool White",				rgb: "#FFF6ED",		h: 52,		s: 19,		l: 96,		],
2 Likes

Is the hue value in angle or percent? And the l parameters are okay? They control the “level” even though they should control the lightness… :slight_smile:

Works for me… I have the Aeon doorbell, I use a contact sensor wired to a traditional button to use the pushButton command for the Aeon. I was getting the error, now I see pushButton. Dunno if it functions, I’m setting things up in CoRE while I sit at work

1 Like

Good question, I’m not sure about whether the values I input represent angle or percent.

To be honest I haven’t delved too deeply into your code but I’m assuming that the “h” values as I’ve set them get divided by 3.6 in your code. So if they are being divided (example: Soft White with an “h” value of 23 / 3.6 = 6.4, rounded down to 6)

The “l” parameters seem to be fine as is, I didn’t change them.

Not sure if the “rgb” values are correct or not.

1 Like

Where did you enter these colors? In the setColor action in the UI or did you change the CoRE code? The CoRE code uses percentage (still), but the setColor action where you enter the H, S and L uses angle. I’ll update all the CoRE color list to also use angle and do the 3.6 division in code.

In the code itself, specifically in the private colors() block

And then in the UI I selected a specific color (ex. Soft White, Warm White, etc.)

1 Like

Okay, so they’re percentages, I’ll change them and update. Thank you :slight_smile:

1 Like

@ady624 Not sure if this has been requested but would it be possible to put a ramp up capability for a dimmable light. I know it could be done with a bunch of toggles and waits but would be nice if it could be done like the flash capability where we just input a starting light level, ending light level and duration and CoRE figures out the math and sets it. Example is a wake for my daughter in the morning, I want it to turn on her light at 5:45am at 10% and keep increasing it until 6:15 where it should be at 100% changing the level say every minute or let that be a selection of seconds, minutes or hours if someone wanted.

2 Likes

Hmmmmm… @ady624 I updated to the most recent version and now I get a red flag when trying to access existing pistons.

The logs are saying it’s a timeout.

But, I can create new pistons.

1 Like