Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#872 #885

Merged
merged 9 commits into from
Jan 5, 2023
Merged

#872 #885

merged 9 commits into from
Jan 5, 2023

Conversation

proddy
Copy link
Contributor

@proddy proddy commented Jan 3, 2023

No description provided.

@@ -240,10 +240,12 @@ StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings)

String old_local = settings.locale;
settings.locale = root["locale"] | EMSESP_DEFAULT_LOCALE;
check_flag(prev, settings.low_clock, ChangeFlags::RESTART);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a copy&paste, it makes no sense here.

const DeviceIcon: FC<DeviceIconProps> = ({ type_id }) => {
switch (type_id) {
case 1:
case 2:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a enum here, then it's easier to check against emsdevice.h.

// matches emsdevice.h DeviceType
const enum DeviceType {
  SYSTEM = 0,
  DALLASSENSOR,
  ANALOGSENSOR,
  BOILER,
  THERMOSTAT,
  MIXER,
  SOLAR,
  HEATPUMP,
  GATEWAY,
  SWITCH,
  CONTROLLER,
  CONNECT,
  ALERT,
  PUMP,
  GENERIC,
  HEATSOURCE,
  UNKNOWN
}

const DeviceIcon: FC<DeviceIconProps> = ({ type_id }) => {
  switch (type_id) {
    case DeviceType.DALLASSENSOR:
    case DeviceType.ANALOGSENSOR:
      return <MdOutlineSensors />;
    case DeviceType.BOILER:
    case DeviceType.HEATSOURCE:
      return <CgSmartHomeBoiler />;
    case DeviceType.THERMOSTAT:
      return <MdThermostatAuto />;
    case DeviceType.MIXER:
      return <AiOutlineControl />;
    case DeviceType.SOLAR:
      return <FaSolarPanel />;
    case DeviceType.HEATPUMP:
      return <GiHeatHaze />;
    case DeviceType.GATEWAY:
      return <AiOutlineGateway />;
    case DeviceType.SWITCH:
      return <TiFlowSwitch />;
    case DeviceType.CONTROLLER:
    case DeviceType.CONNECT:
      return <VscVmConnect />;
    case DeviceType.ALERT:
      return <AiOutlineAlert />;
    case DeviceType.PUMP:
      return <AiOutlineChrome />;
    default:
      return null;
  }
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes much better. I'll update

@proddy proddy merged commit 74acf2f into emsesp:dev Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants