Add SmartHome and relevant config

This commit is contained in:
Ceda EI 2021-01-04 12:18:38 +05:30
parent 031c1ede21
commit 4bdcd49e1f
4 changed files with 44 additions and 2 deletions

View File

@ -16,7 +16,7 @@ function Core() {
data: coreState.data,
close: () => dispatch(setPlugin(false))
};
const dummyButtons = ["Maps", "Home Devices", "Phone"];
const dummyButtons = ["Maps", "Phone"];
return <>
<Box height="5vh" background="light-1" justify="center" direction="row">
{voiceState.recording ? <VoiceBars style={{height: "100%"}}/>:
@ -39,6 +39,8 @@ function Core() {
<Box direction="row" margin="1.5em" wrap={true}>
<Button onClick={() => dispatch(setPlugin("petMode"))} primary
label="Pet Mode" />
<Button onClick={() => dispatch(setPlugin("smartHome"))} primary
label="Smart Home" margin="0 0 0 1em" />
{dummyButtons.map(i =>
<Button primary label={i} key={i} margin="0 0 0 1em" />
)}

37
src/plugins/SmartHome.js Normal file
View File

@ -0,0 +1,37 @@
import React, {useState, useEffect} from "react";
import PropTypes from "prop-types";
import { Box, Button } from "grommet";
import { CAMERA_URL } from "../config";
function SmartHome(props) {
const [ idx, setIdx ] = useState(0);
useEffect(() => {
const id = setInterval(() => setIdx(i => i + 1), 20);
return () => clearInterval(id);
}, []);
return (
<Box
align="center"
background="light-1"
width="100vw"
justify="center"
direction="column"
alignContent="center"
height="95vh"
>
<img src={`${CAMERA_URL}?id=${idx}`} />
<Button primary size="large" onClick={props.close}
label="Dismiss" margin="1.5em" />
</Box>
);
}
SmartHome.propTypes = {
data: PropTypes.object,
close: PropTypes.func
};
SmartHome.pluginName = "Smart Home";
export default SmartHome;

View File

@ -3,6 +3,7 @@ import Manual from "./Manual";
import Temperature from "./Temperature";
import Accident from "./Accident";
import PetMode from "./PetMode";
import SmartHome from "./SmartHome";
export default {
warning: Warning,
@ -10,4 +11,5 @@ export default {
temperature: Temperature,
accident: Accident,
petMode: PetMode,
smartHome: SmartHome,
};

View File

@ -2,5 +2,6 @@ const WS_BASE = "http://localhost:5050/";
const TG_API = "xxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxx";
const TG_USERID = 123456789;
const CAR_API = "http://localhost:5000/";
const CAMERA_URL = "http://path.to/still/image.jpg";
export { WS_BASE, TG_API, TG_USERID, CAR_API };
export { WS_BASE, TG_API, TG_USERID, CAR_API, CAMERA_URL };