Lutron Caseta Interface

Yeah Python scripts are excellent for working with the powerful capabilities of the Pico remote… but FYI, you can remove all but one of your automations and have the same functionality you could trim that way down.

Just use Python variables in your script to store the integer values of the Pico sensors, you could eliminate all of your Automation code except for just one of them… saving tons of lines of automation code to manage.

#At the top of your Python script...
PICO_ON = 1
PICO_FAV = 2
PICO_OFF = 4
PICO_UP = 8
PICO_DOWN  = 16

I have mine working with one simple automation for each pico remote (vs a copy/paste automate for all 5 states for each remote), that calls one Python script to handle all the logic and various scenarios I want that remote to support.

Example Automation:

  #This controls the normal 5 Buttom Pico Dimmer Switch to sync up with the build in Lutron States!
  - alias: Living Room Caseta Pico Switch
    hide_entity: True
    trigger:
      #We want to Trigger on ANY state change, therefore no from/to value is specified
      platform: state
      entity_id: sensor.living_room_pico
    action:
      - service: python_script.pico_living_room_switch

###Python Script:

# Obtain status of the Pico Remote
pico_status = hass.states.get("sensor.living_room_pico")
pico_state_value = int(pico_status.state)

#DEBUG Notification via Pushover
#hass.services.call("notify", "pushover", {"message": "Living Room Pico Switch [Pico={0}]".format(pico_state_value)})

service_data = { "entity_id": "group.living_room_lamps" }

#NOTE: On button == 1 (Full ON)
#NOTE: Center scene button == 2 (Center Scene Button)
if pico_state_value == 1 or pico_state_value == 2:
	#For full ON state we set to 100% brightness
	service_data["brightness_pct"] = 100
	hass.services.call("light", "turn_on", service_data)

#NOTE: Off button == 4 (Full OFF)
elif pico_state_value == 4:
	#For full OFF state we turn the lights off
	hass.services.call("light", "turn_off", service_data)
2 Likes