refactor: update VehicleMechanics to use LabledDropdown for start and end point selection; clean up unused MQTT code and improve zone data fetching logic
This commit is contained in:
@@ -6,37 +6,37 @@ const MqttEvents = () => {
|
||||
const { setTouch, setTemperature, setHumidity } = useDrieUIValue();
|
||||
useEffect(() => {
|
||||
|
||||
const client = mqtt.connect(`ws://${process.env.REACT_APP_SERVER_MQTT_URL}`);
|
||||
// const client = mqtt.connect(`ws://${process.env.REACT_APP_SERVER_MQTT_URL}`);
|
||||
|
||||
client.subscribe("touch");
|
||||
client.subscribe("temperature");
|
||||
client.subscribe("humidity");
|
||||
// client.subscribe("touch");
|
||||
// client.subscribe("temperature");
|
||||
// client.subscribe("humidity");
|
||||
|
||||
const handleMessage = (topic: string, message: any) => {
|
||||
const value = message.toString();
|
||||
// const handleMessage = (topic: string, message: any) => {
|
||||
// const value = message.toString();
|
||||
|
||||
if (topic === "touch") {
|
||||
setTouch(value);
|
||||
} else if (topic === "temperature") {
|
||||
setTemperature(parseFloat(value));
|
||||
} else if (topic === "humidity") {
|
||||
setHumidity(parseFloat(value));
|
||||
}
|
||||
};
|
||||
// if (topic === "touch") {
|
||||
// setTouch(value);
|
||||
// } else if (topic === "temperature") {
|
||||
// setTemperature(parseFloat(value));
|
||||
// } else if (topic === "humidity") {
|
||||
// setHumidity(parseFloat(value));
|
||||
// }
|
||||
// };
|
||||
|
||||
client.on("message", handleMessage);
|
||||
// client.on("message", handleMessage);
|
||||
|
||||
client.on("error", (err) => {
|
||||
console.error("MQTT Connection Error:", err);
|
||||
});
|
||||
// client.on("error", (err) => {
|
||||
// console.error("MQTT Connection Error:", err);
|
||||
// });
|
||||
|
||||
client.on("close", () => {
|
||||
console.log("MQTT Connection Closed");
|
||||
});
|
||||
// client.on("close", () => {
|
||||
// console.log("MQTT Connection Closed");
|
||||
// });
|
||||
|
||||
return () => {
|
||||
client.end();
|
||||
};
|
||||
// return () => {
|
||||
// client.end();
|
||||
// };
|
||||
}, [setTouch, setTemperature, setHumidity]);
|
||||
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
console.log("url_Backend_dwinzo: ", url_Backend_dwinzo);
|
||||
|
||||
export const getSelect2dZoneData = async (
|
||||
ZoneId?: string,
|
||||
|
||||
Reference in New Issue
Block a user