Cycle Power Switch

I was trying to use ChatGPT to create a rule to turn power on for 4 hour then off for 3, but the instruction that came back do not appear to match up with the current version of Rule Machine. Can someone help me with modifying these instructions to work? I am currently getting stuck at steps 3 and 4 of Create the Actions

  1. Log in to your Hubitat dashboard.
  2. Click on "Apps" in the top menu.
  3. Click on "Rule Machine 5.1" to open the Rule Machine app.

Create the Rule:

  1. Click on "Create New Rule" to start creating a new rule.
  2. Give your rule a name, such as "Repeat Tablet Power Toggle."

Define the Trigger:

  1. Under "Select Trigger Event," choose the appropriate trigger event that will activate the rule. For example, you can select a specific time of the day or a trigger based on some other condition.

Create the Actions:

  1. In the "Define Actions to Run" section, click on "Conditional Actions."
  2. In the conditional action, click on "IF (Condition) THEN" and choose "Simple Conditional."
  3. For the "IF (Condition) THEN" section, select "Elapsed Time."
  4. Set the elapsed time condition to "4 hours" and choose "Cancel" for the "Repeat Options."
  5. Click on "Select Actions to Run" within the "IF (Condition) THEN" section.
  6. Click on "Toggle" in the "Action Type" section.
  7. Select "Tablet Power" from the list of devices or switches.
  8. Under "Action for True," select "Turn On" to turn the Tablet Power on.
  9. Click on "Done with Actions" to close the "Toggle" action.
  10. Click on "Done" to close the "IF (Condition) THEN" section.

Create the Repeat Actions:

  1. Click on "Create Repeating Actions" to add a repeat loop for the rule.
  2. In the "Create Repeating Actions" section, click on "FOR" and set the duration to "3 hours."
  3. Click on "Select Actions to Run" within the "Create Repeating Actions" section.
  4. Click on "Toggle" in the "Action Type" section.
  5. Select "Tablet Power" from the list of devices or switches.
  6. Under "Action for True," select "Turn Off" to turn the Tablet Power off.
  7. Click on "Done with Actions" to close the "Toggle" action.
  8. Click on "Done" to close the "Create Repeating Actions" section.
  9. Click on "Done" to close the "Define Actions to Run" section.

Save the Rule:

  1. Click on "Save Rule" to save the complete rule.

With this rule, the "Tablet Power" device will be turned on automatically when the rule is triggered. It will remain on for 4 hours, then turn off for 3 hours, and then the cycle will repeat.

I would just do something like this. After creating the rule turn the switch off and then back on, and from that point on it should cycle.

1 Like

It'll cycle until the next hub reboot.

I have a rule (on each hub) that triggers on "Location event: systemStart" to restart rules like that, set the hub's clock, and otherwise return things to "normal" after a reboot.

It will start cycling again on a hub reboot. If you need a precise 4 hours on 3 hours off every time, then it gets a bit more complicated.

Thanks for your help with this. What happens after a hub reboot. Will the switch always turn on or will it be the same state that it was before the reboot?

The trigger that starts the rule is the switch turning on or a reboot, so the first IF statement can only be true if the rule was triggered by a reboot.

So if the switch is off at reboot it will get turned on and exit the rule. This will start the on cycle and will turn it back off in 4 hours. If the switch is on at reboot then it will get turned off for 3 hours and then turned back on.

This is a simple way of doing it. If you need to track the state of the switch and make sure it cycles correctly every time no matter what, that can be done. It gets a bit more complicated, however

The way you described it working is how I want it to work. Thanks again for your help with this.

I'm able to define the Trigger portion, but I'm unable to create the Action part. Can you provide the details?

I seem to be missing some Actions. May I see the code (after/below the On: AAA Test Switch statement)?
I think there's another Wait for event -> elapsed time 4:00:00

That's all there is. What is or is not happening to make you think there is more?