diff --git a/src/plugins/SmartHome.js b/src/plugins/SmartHome.js index 0e86567..fdc3102 100644 --- a/src/plugins/SmartHome.js +++ b/src/plugins/SmartHome.js @@ -1,8 +1,9 @@ import React, {useState, useEffect} from "react"; import PropTypes from "prop-types"; import { Box, Button } from "grommet"; +import axios from "axios"; -import { CAMERA_URL } from "../config"; +import { CAMERA_URL, LIGHTS_URL } from "../config"; function SmartHome(props) { const [ idx, setIdx ] = useState(0); @@ -10,6 +11,12 @@ function SmartHome(props) { const id = setInterval(() => setIdx(i => i + 1), 20); return () => clearInterval(id); }, []); + function turnOn() { + axios.get(`${LIGHTS_URL}/on`); + } + function turnOff() { + axios.get(`${LIGHTS_URL}/off`); + } return ( + +