Skip to content

Commit 8e85292

Browse files
committed
fix README
1 parent 42c70a6 commit 8e85292

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,11 @@ mqtt_settings = Settings.MQTT(host="localhost")
180180

181181
# Information about the climate entity
182182
climate_info = ClimateInfo(
183-
name="MyThermostat",
183+
name="MyClimate",
184184
temperature_unit="C",
185185
min_temp=16,
186186
max_temp=32,
187-
modes=["off", "heat", "cool", "auto"],
188-
current_temperature_topic="home/thermostat/temperature"
187+
modes=["off", "heat"]
189188
)
190189

191190
settings = Settings(mqtt=mqtt_settings, entity=climate_info)
@@ -198,24 +197,25 @@ def my_callback(client: Client, user_data, message: MQTTMessage):
198197
except ValueError:
199198
print("Ony JSON schema is supported for climate entities!")
200199
return
201-
202-
# Handle the command (e.g., mode changes, temperature setpoints)
203-
handle_climate_command(payload)
204-
# Update the state in HA
205-
my_climate.set_temperature(25.0)
206-
my_climate.set_mode("heat")
200+
201+
if payload['command'] == "mode":
202+
set_my_custom_climate_mode(payload['value'])
203+
elif payload['command'] == "temperature":
204+
set_my_custom_climate_temperature(payload['value'])
205+
else:
206+
print("Unknown command")
207207

208208
# Define an optional object to be passed back to the callback
209209
user_data = "Some custom data"
210210

211211
# Instantiate the climate entity
212212
my_climate = Climate(settings, my_callback, user_data)
213213

214-
# Update the current temperature reading
215-
my_climate.update_current_temperature(24.5)
214+
# Set the current temperature
215+
my_climate.set_current_temperature(24.5)
216216

217217
# Set the target temperature
218-
my_climate.set_temperature(25.0)
218+
my_climate.set_target_temperature(25.0)
219219

220220
# Change the HVAC mode
221221
my_climate.set_mode("heat")

0 commit comments

Comments
 (0)