/** 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 { CircularThumbStyle, KnobDimmerStyle, KnobProgress, textStyle, knobIcon, knobContainer, } from "./DimmerStyle"; import { RemoteService } from "../../../remote"; import { connect } from "react-redux"; export class ButtonDimmerComponent extends Component { increaseIntensity = () => { this.props.device.buttonDimmerDim(this.props.id, "UP") .catch((err) => console.error('button dimmer increase error', err)); }; decreaseIntensity = () => { this.props.device.buttonDimmerDim(this.props.id, "DOWN") .catch((err) => console.error('button dimmer decrease error', err)); }; render() { return ( icon Button Dimmer + ); } } export class KnobDimmerComponent extends Component { setIntensity = (newValue) => { const val = Math.round(newValue * 100); this.props.device.knobDimmerDimTok(this.props.id, val) .catch((err) => console.error('knob dimmer set intensity error', err)); }; render() { return (
Knob Dimmer Knob Icon
); } } const mapStateToProps = (state, ownProps) => ({ device: state.devices[ownProps.id], }); const conn = connect(mapStateToProps, RemoteService); export const KnobDimmer = conn(KnobDimmerComponent); export const ButtonDimmer = conn(ButtonDimmerComponent);