Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
React Homey – declerative home automation
/*
Disclaimer: This is just a drafted api and not real (yet).
*/
import ReactHomey, {
// Components
Light,
Fan,
Room,
// Hooks
useGetDevices,
useSensor,
useTrigger
} from "react-homey"
const Home = () => {
const {getIdByName} = useGetDevices()
const {temperature} = useSensor(getIdByName("Thermostat"))
const isHighTemperature = temperature > 25
useTrigger(() => {
console.log("Someone pressed the button.")
}, getIdByName("My Button"))
return (
<Room>
<Fan level={isHighTemperature ? 1 : 0}/>
<Light id={getIdByName("Living room lamp")} power={true} brightness={0.8} />
</Room>
)
}
ReactHomey.render(<Home/>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.