Skip to content

Instantly share code, notes, and snippets.

@aigarius
aigarius / shelly_with_ha.js
Created April 12, 2023 10:48
Shelly script to revert to direct switch control if Home Assistant is not available
// Preconditions:
// Shelly connected to a manual switch and to a smart light
// Shelly set to disconnected mode and to restore power to on after power loss
// Input mode is button (might need a minor change for switch - untested)
// Shelly is added to Home Assistant
// An automation is created in Home Assistant to toggle the light when single button press is
// detected on the Shelly (other automations may also exist)
let online_status = 0;
// Change this to the URL of your Home Assistant base URL + "/api/ping"