/** Users can add dimmers, a particular kind of switch that can also modify the intensity level of a given light. There are two types of dimmers: • A dimmer with state stores a given intensity level and sets the light to that level. <-- StatefulDimmer • A dimmer without state can just increase or decrease the intensity of a light. <-- DefualtDimmer The user can change the state of a dimmer through an intuitive UI in SmartHut . **/ import React, { Component } from "react"; import { CircularInput, CircularProgress, CircularThumb, } from "react-circular-input"; import { ButtonDimmerContainer, MinusPanel, PlusPanel, ThumbText, } from "./styleComponents"; import Settings from "./DeviceSettings"; import { CircularThumbStyle, KnobDimmerStyle, KnobProgress, textStyle, knobIcon, knobContainer, } from "./DimmerStyle"; import { call } from "../../../client_server"; export class ButtonDimmer extends Component { constructor(props) { super(props); this.state = {}; } increaseIntensity = () => { let data = { dimType: "UP", id: this.props.device.id, }; call.deviceUpdate(data, "buttonDimmer/dim").then((res) => { if (res.status === 200) { } }); }; decreaseIntensity = () => { let data = { dimType: "DOWN", id: this.props.device.id, }; call.deviceUpdate(data, "buttonDimmer/dim").then((res) => { if (res.status === 200) { } }); }; componentDidMount() {} render() { return ( this.props.onChangeData(id, newSettings) } /> icon {this.props.device.name} ({this.props.device.id}) + ); } } export class KnobDimmer extends Component { constructor(props) { super(props); this.state = { pointingDevices: [], value: 1, }; } setIntensity = (newValue) => { let val = Math.round(newValue * 100) <= 1 ? 1 : Math.round(newValue * 100); let data = { id: this.props.device.id, intensity: val, }; call.deviceUpdate(data, "knobDimmer/dimTo").then((res) => { if (res.status === 200) { this.setState({ value: val, }); } }); }; componentDidMount() { this.setState({ value: 1, }); } render() { return (
this.props.onChangeData(id, newSettings) } /> {this.props.device.name} ({this.props.device.id}) Knob Icon
); } }