A Home Assistant integration that allows cycling through a list of entities (lights, switches, scenes) with manual and automatic controls, including a custom Lovelace card for easy interaction.
- Entity Cycling: Create State Cycler entities that manage lists of lights, switches, scenes, and other entities
- Manual Control: Cycle through states with next/previous buttons or jump to specific states
- Automatic Cycling: Optional timer for automatic state transitions
- Smart Toggle: Toggle between on/off states, remembering previous settings
- Cycle Mode: Special cycling logic for button presses with timeout behavior
- State Preservation: Remembers and restores entity states (brightness, color, etc.) when cycling back
- Custom Lovelace Card: Beautiful card for Lovelace dashboards with state display and controls
- Events & Automation: Fires events for all state changes to enable powerful automations
- Multiple Entities: Create multiple independent State Cycler entities
- Configuration UI: Easy setup through Home Assistant's integration configuration flow
Or manually:
- Open HACS in Home Assistant
- Click on "Integrations"
- Click the three dots in the top right corner
- Select "Custom repositories"
- Add
https://github.com/luckydonald/hoass_state-cyclerand select "Integration" as the category - Click "Install"
- Restart Home Assistant
- Download the latest release from GitHub Releases
- Copy the
custom_components/state_cyclerfolder to yourcustom_componentsdirectory - Copy the built frontend file
state-cycler-card.jsto yourwwwfolder (or serve it via your web server) - Restart Home Assistant
After installation, add the State Cycler integration through the Home Assistant UI:
- Go to Settings → Devices & Services → Add Integration
- Search for "State Cycler" and select it
- Configure your State Cycler entity:
- Name: Friendly name for the entity
- States: List of entity IDs to cycle through (lights, switches, scenes, etc.)
- Include Off State: Whether to include an "off" state in the cycle
- Timer Interval: Optional automatic cycling interval in seconds
Add the State Cycler card to your Lovelace dashboard:
type: custom:state-cycler-card
entity: state_cycler.your_cycler_name
title: My State Cycler # OptionalThe card displays:
- Current active state with friendly name and index
- Toggle button (on/off)
- Next button for manual cycling
- Cycle button with smart timeout logic
- List of all configured states with active highlighting
The State Cycler provides several services you can call:
state_cycler.next: Cycle to next statestate_cycler.prev: Cycle to previous statestate_cycler.to: Jump to specific index (provideindexparameter)state_cycler.off: Turn off all statesstate_cycler.on: Turn on last active statestate_cycler.switch: Toggle on/offstate_cycler.cycle: Smart cycling with timeout
Example automation:
automation:
- alias: "Cycle lights on button press"
trigger:
platform: state
entity_id: binary_sensor.button
to: "on"
action:
service: state_cycler.cycle
target:
entity_id: state_cycler.living_room_lightsThe integration fires events for automation:
state_cycler.cycled: Fired on every state change with details about the transitionstate_cycler.initialized: Fired when entity is loaded/reloadedstate_cycler.cycle_timeout: Fired when cycle mode times out
The State Cycler entity exposes these attributes:
state: Current state (offor entity_id)state_friendly: Friendly name of current stateindex: Current index (-1 if off)toggle_state: Boolean on/off statusinclude_off_state: Whether off state is included in cyclelast_state: Previously active statelast_index: Previously active indextimer_interval: Auto-cycle interval (null if disabled)states: List of configured entity IDs
Create a State Cycler for bedroom lights:
# Configuration
name: "Bedroom Lights"
states:
- light.bedroom_main
- light.bedroom_lamp
- scene.bedroom_cozy
include_off_state: true
timer_interval: nullCycle through living room scenes every 30 minutes:
name: "Living Room Scenes"
states:
- scene.living_bright
- scene.living_movie
- scene.living_dinner
include_off_state: false
timer_interval: 1800 # 30 minutesUse with a physical button for manual control:
automation:
- alias: "Button cycles kitchen lights"
trigger:
platform: event
event_type: state_cycler.cycled
event_data:
entity_id: state_cycler.kitchen_lights
condition:
condition: template
value_template: "{{ trigger.event.data.command == 'cycle' }}"
action:
- service: notify.mobile_app
data:
message: "Kitchen lights cycled to {{ trigger.event.data.state_friendly }}"Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- state-cycler
- home-assistant
- hacs
- hacs-integration
- homeassistant-integration
- home-assistant-integration
- homeassistant-custom-integration
- custom-card
- homeassistant-custom-card
- lovelace-card
- custom-component
- homeassistant-custom-component
- home-assistant-custom-component-hacs
- luckydonald