-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[radiothermostat] Add Remote Temperature channel #10194
Changes from 3 commits
4c63862
0425025
b3cfe59
25578d5
a818b24
16c81be
596fa6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,7 +216,7 @@ public void dispose() { | |
} | ||
|
||
public void handleRawCommand(@Nullable String rawCommand) { | ||
connector.sendCommand(null, null, rawCommand); | ||
connector.sendCommand(null, null, rawCommand, DEFAULT_RESOURCE); | ||
} | ||
|
||
@Override | ||
|
@@ -226,21 +226,19 @@ public void handleCommand(ChannelUID channelUID, Command command) { | |
} else { | ||
Integer cmdInt = -1; | ||
String cmdStr = command.toString(); | ||
if (cmdStr != null) { | ||
try { | ||
// parse out an Integer from the string | ||
// ie '70.5 F' becomes 70, also handles negative numbers | ||
cmdInt = NumberFormat.getInstance().parse(cmdStr).intValue(); | ||
} catch (ParseException e) { | ||
logger.debug("Command: {} -> Not an integer", cmdStr); | ||
} | ||
try { | ||
// parse out an Integer from the string | ||
// ie '70.5 F' becomes 70, also handles negative numbers | ||
cmdInt = NumberFormat.getInstance().parse(cmdStr).intValue(); | ||
} catch (ParseException e) { | ||
logger.debug("Command: {} -> Not an integer", cmdStr); | ||
} | ||
|
||
switch (channelUID.getId()) { | ||
case MODE: | ||
// only do if commanded mode is different than current mode | ||
if (!cmdInt.equals(rthermData.getThermostatData().getMode())) { | ||
connector.sendCommand("tmode", cmdStr); | ||
connector.sendCommand("tmode", cmdStr, DEFAULT_RESOURCE); | ||
|
||
// set the new operating mode, reset everything else, | ||
// because refreshing the tstat data below is really slow. | ||
|
@@ -253,26 +251,26 @@ public void handleCommand(ChannelUID channelUID, Command command) { | |
rthermData.getThermostatData().setProgramMode(-1); | ||
updateChannel(PROGRAM_MODE, rthermData); | ||
|
||
// now just trigger a refresh of the thermost to get the new active setpoint | ||
// now just trigger a refresh of the thermostat to get the new active setpoint | ||
// this takes a while for the JSON request to complete (async). | ||
connector.getAsyncThermostatData(DEFAULT_RESOURCE); | ||
} | ||
break; | ||
case FAN_MODE: | ||
rthermData.getThermostatData().setFanMode(cmdInt); | ||
connector.sendCommand("fmode", cmdStr); | ||
connector.sendCommand("fmode", cmdStr, DEFAULT_RESOURCE); | ||
break; | ||
case PROGRAM_MODE: | ||
rthermData.getThermostatData().setProgramMode(cmdInt); | ||
connector.sendCommand("program_mode", cmdStr); | ||
connector.sendCommand("program_mode", cmdStr, DEFAULT_RESOURCE); | ||
break; | ||
case HOLD: | ||
if (command instanceof OnOffType && command == OnOffType.ON) { | ||
rthermData.getThermostatData().setHold(1); | ||
connector.sendCommand("hold", "1"); | ||
connector.sendCommand("hold", "1", DEFAULT_RESOURCE); | ||
} else if (command instanceof OnOffType && command == OnOffType.OFF) { | ||
rthermData.getThermostatData().setHold(0); | ||
connector.sendCommand("hold", "0"); | ||
connector.sendCommand("hold", "0", DEFAULT_RESOURCE); | ||
} | ||
break; | ||
case SET_POINT: | ||
|
@@ -287,7 +285,14 @@ public void handleCommand(ChannelUID channelUID, Command command) { | |
// don't do anything if we are not in heat or cool mode | ||
break; | ||
} | ||
connector.sendCommand(cmdKey, cmdInt.toString()); | ||
connector.sendCommand(cmdKey, cmdInt.toString(), DEFAULT_RESOURCE); | ||
break; | ||
case REMOTE_TEMP: | ||
if (cmdInt != -1) { | ||
connector.sendCommand("rem_temp", cmdInt.toString(), REMOTE_TEMP_RESOURCE); | ||
} else { | ||
connector.sendCommand("rem_mode", "0", REMOTE_TEMP_RESOURCE); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should make sure that the units are what you expect before you send the command to the device. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am already parsing out the value of the command string into a whole number on line 232. This device is US centric and only supports Fahrenheit so it should already be understood by the user that they are sending a Fahrenheit temperature value to it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That may be the case but the user might be using Celsius as their system default so the UI would end up displaying and sending values with that unit instead. Certain countries have easy access to products that use Fahrenheit even though they actually use celsius. E.g. Canada. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to recap this functionality a bit... This new channel is a write-only channel, it does not display anything back, It allows a user to override the internal temperature reading of this thermostat with a temperature value from an external sensor. Presumably a rule would be used to monitor an item containing a temperature sensor's value and when it changes, it would update an item linked to this channel. What ever number is received by the thermostat would then display on its screen as the current temperature reading (a whole number Fahrenheit value) and then be sent back to the main temperature channel (and displayed per whatever unit is specified by their system default settings) when the binding does its next polling update. I am sure that there are a few of these in Canada even though it was not sold there..... |
||
break; | ||
default: | ||
logger.warn("Unsupported command: {}", command.toString()); | ||
|
@@ -320,7 +325,10 @@ public void onNewMessageEvent(RadioThermostatEvent event) { | |
updateAllChannels(); | ||
break; | ||
case HUMIDITY_RESOURCE: | ||
rthermData.setHumidity(gson.fromJson(evtVal, RadioThermostatHumidityDTO.class).getHumidity()); | ||
RadioThermostatHumidityDTO dto = gson.fromJson(evtVal, RadioThermostatHumidityDTO.class); | ||
if (dto != null) { | ||
rthermData.setHumidity(dto.getHumidity()); | ||
} | ||
updateChannel(HUMIDITY, rthermData); | ||
break; | ||
case RUNTIME_RESOURCE: | ||
|
@@ -382,7 +390,7 @@ private void updateChannel(String channelId, RadioThermostatDTO rthermData) { | |
|
||
/** | ||
* Update a given channelId from the thermostat data | ||
* | ||
* | ||
* @param the channel id to be updated | ||
* @param data the RadioThermostat dto | ||
* @return the value to be set in the state | ||
|
@@ -456,7 +464,7 @@ private void updateAllChannels() { | |
|
||
/** | ||
* Build a list of fan modes based on what model thermostat is used | ||
* | ||
* | ||
* @return list of state options for thermostat fan modes | ||
*/ | ||
private List<StateOption> getFanModeOptions() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please just make the recommended change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, done.