import classNames from 'classnames'
import { ThermostatCoolIcon } from 'lib/icons/ThermostatCool.js'
import { ThermostatHeatIcon } from 'lib/icons/ThermostatHeat.js'
import { ThermostatHeatCoolIcon } from 'lib/icons/ThermostatHeatCool.js'
import { ThermostatOffIcon } from 'lib/icons/ThermostatOff.js'
import type { ClimateSetting } from 'lib/seam/thermostats/thermostat-device.js'
import { Temperature } from 'lib/ui/thermostat/Temperature.js'
interface ClimateSettingStatusProps {
climateSetting: ClimateSetting
temperatureUnit?: 'fahrenheit' | 'celsius'
iconPlacement?: 'left' | 'right'
}
export function ClimateSettingStatus({
climateSetting,
temperatureUnit = 'fahrenheit',
iconPlacement = 'left',
}: ClimateSettingStatusProps): JSX.Element {
return (
{iconPlacement === 'left' && (
)}
{iconPlacement === 'right' && (
)}
)
}
function ClimateSettingIcon(props: {
mode: ClimateSetting['hvac_mode_setting']
}): JSX.Element | null {
const { mode } = props
return (
{mode === 'cool' && }
{mode === 'heat' && }
{mode === 'heat_cool' && }
{mode === 'off' && }
)
}
interface SetPoint {
fahrenheit: number
celsius: number
}
function Content(props: {
mode: ClimateSetting['hvac_mode_setting']
coolingSetPoint: Partial
heatingSetPoint: Partial
temperatureUnit: 'fahrenheit' | 'celsius'
}): JSX.Element | null {
const { mode, coolingSetPoint, heatingSetPoint, temperatureUnit } = props
if (mode === 'cool' && isSetPoint(coolingSetPoint))
return
if (mode === 'heat' && isSetPoint(heatingSetPoint))
return
if (
mode === 'heat_cool' &&
isSetPoint(heatingSetPoint) &&
isSetPoint(coolingSetPoint)
)
return (
{' - '}
)
if (mode === 'off') return {t.off}
return null
}
const isSetPoint = (setPoint: Partial): setPoint is SetPoint => {
return setPoint.fahrenheit != null && setPoint.celsius != null
}
const t = {
off: 'Off',
}