private void SendAllValues() { var room = GetRoom(); if (null != room) { var roomnumberupdate = new Json.SetValue() { type = "property_update", value_name = "prop_number", value = RoomNumber }; Send(JsonConvert.SerializeObject(roomnumberupdate)); var ambientTemp = new Json.SetValue() { type = "property_update", value_name = "ambient_temperature", value = room.AmbientTemperature }; Send(JsonConvert.SerializeObject(ambientTemp)); var sunState = new Json.SetValue() { type = "property_update", value_name = "sun_state", value = room.SunState }; Send(JsonConvert.SerializeObject(sunState)); var windSpeed = new Json.SetValue() { type = "property_update", value_name = "wind_speed", value = GetRoom().WindSpeed }; Send(JsonConvert.SerializeObject(windSpeed)); var windDirection = new Json.SetValue() { type = "property_update", value_name = "wind_direction", value = GetRoom().WindDirection }; Send(JsonConvert.SerializeObject(windDirection)); var userdefined_double_1 = new Json.SetValue() { type = "property_update", value_name = "userdefined_double_1", value = GetRoom().UserDefinedDouble1 }; Send(JsonConvert.SerializeObject(userdefined_double_1)); var userdefined_double_2 = new Json.SetValue() { type = "property_update", value_name = "userdefined_double_2", value = GetRoom().UserDefinedDouble2 }; Send(JsonConvert.SerializeObject(userdefined_double_2)); var userdefined_double_3 = new Json.SetValue() { type = "property_update", value_name = "userdefined_double_3", value = GetRoom().UserDefinedDouble3 }; Send(JsonConvert.SerializeObject(userdefined_double_3)); var userdefined_string_1 = new Json.SetValue() { type = "property_update", value_name = "userdefined_string_1", value = GetRoom().UserDefinedString1 }; Send(JsonConvert.SerializeObject(userdefined_string_1)); var userdefined_string_2 = new Json.SetValue() { type = "property_update", value_name = "userdefined_string_2", value = GetRoom().UserDefinedString2 }; Send(JsonConvert.SerializeObject(userdefined_string_2)); var userdefined_string_3 = new Json.SetValue() { type = "property_update", value_name = "userdefined_string_3", value = GetRoom().UserDefinedString3 }; Send(JsonConvert.SerializeObject(userdefined_string_3)); var room4thTemp = new Json.SetValue() { type = "property_update", value_name = "room4th_temperature", value = GetRoom().Room4thTemperature }; Send(JsonConvert.SerializeObject(room4thTemp)); var room4thPresenceState = new Json.SetValue() { type = "property_update", value_name = "room4th_presence_state", value = GetRoom().Room4thPresenceState }; Send(JsonConvert.SerializeObject(room4thPresenceState)); var room4thAirState = new Json.SetValue() { type = "property_update", value_name = "room4th_air_state", value = GetRoom().Room4thAirState }; Send(JsonConvert.SerializeObject(room4thAirState)); var room4thLightState = new Json.SetValue() { type = "property_update", value_name = "room4th_light_state", value = GetRoom().Room4thLightState }; Send(JsonConvert.SerializeObject(room4thLightState)); var room4thWindowState = new Json.SetValue() { type = "property_update", value_name = "room4th_window_state", value = GetRoom().Room4thWindowState }; Send(JsonConvert.SerializeObject(room4thWindowState)); var room4thHeaterState = new Json.SetValue() { type = "property_update", value_name = "room4th_heater_state", value = GetRoom().Room4thHeaterState }; Send(JsonConvert.SerializeObject(room4thHeaterState)); var room4thBlindState = new Json.SetValue() { type = "property_update", value_name = "room4th_blind_state", value = GetRoom().Room4thBlindState }; Send(JsonConvert.SerializeObject(room4thBlindState)); var room2ndTemp = new Json.SetValue() { type = "property_update", value_name = "room2nd_temperature", value = GetRoom().Room2ndTemperature }; Send(JsonConvert.SerializeObject(room2ndTemp)); var room2ndPresenceState = new Json.SetValue() { type = "property_update", value_name = "room2nd_presence_state", value = GetRoom().Room2ndPresenceState }; Send(JsonConvert.SerializeObject(room2ndPresenceState)); var room2ndAirState = new Json.SetValue() { type = "property_update", value_name = "room2nd_air_state", value = GetRoom().Room2ndAirState }; Send(JsonConvert.SerializeObject(room2ndAirState)); var room2ndLightState = new Json.SetValue() { type = "property_update", value_name = "room2nd_light_state", value = GetRoom().Room2ndLightState }; Send(JsonConvert.SerializeObject(room2ndLightState)); var room2ndWindowState = new Json.SetValue() { type = "property_update", value_name = "room2nd_window_state", value = GetRoom().Room2ndWindowState }; Send(JsonConvert.SerializeObject(room2ndWindowState)); var room2ndHeaterState = new Json.SetValue() { type = "property_update", value_name = "room2nd_heater_state", value = GetRoom().Room2ndHeaterState }; Send(JsonConvert.SerializeObject(room2ndHeaterState)); var room2ndBlindState = new Json.SetValue() { type = "property_update", value_name = "room2nd_blind_state", value = GetRoom().Room2ndBlindState }; Send(JsonConvert.SerializeObject(room2ndBlindState)); } }
private void SendValue(string valueName) { string json; switch (valueName) { case "ambient_temperature": var ambientTemp = new Json.SetValue() { type = "property_update", value_name = "ambient_temperature", value = GetRoom().AmbientTemperature }; json = JsonConvert.SerializeObject(ambientTemp); SendJsonToAllClients(json); break; case "sun_state": var sunState = new Json.SetValue() { type = "property_update", value_name = "sun_state", value = GetRoom().SunState }; json = JsonConvert.SerializeObject(sunState); SendJsonToAllClients(json); break; case "wind_speed": var windSpeed = new Json.SetValue() { type = "property_update", value_name = "wind_speed", value = GetRoom().WindSpeed }; json = JsonConvert.SerializeObject(windSpeed); SendJsonToAllClients(json); break; case "wind_direction": var windDirection = new Json.SetValue() { type = "property_update", value_name = "wind_direction", value = GetRoom().WindDirection }; json = JsonConvert.SerializeObject(windDirection); SendJsonToAllClients(json); break; case "userdefined_double_1": var userdefined_double_1 = new Json.SetValue() { type = "property_update", value_name = "userdefined_double_1", value = GetRoom().UserDefinedDouble1 }; json = JsonConvert.SerializeObject(userdefined_double_1); SendJsonToAllClients(json); break; case "userdefined_double_2": var userdefined_double_2 = new Json.SetValue() { type = "property_update", value_name = "userdefined_double_2", value = GetRoom().UserDefinedDouble2 }; json = JsonConvert.SerializeObject(userdefined_double_2); SendJsonToAllClients(json); break; case "userdefined_double_3": var userdefined_double_3 = new Json.SetValue() { type = "property_update", value_name = "userdefined_double_3", value = GetRoom().UserDefinedDouble3 }; json = JsonConvert.SerializeObject(userdefined_double_3); SendJsonToAllClients(json); break; case "userdefined_string_1": var userdefined_string_1 = new Json.SetValue() { type = "property_update", value_name = "userdefined_string_1", value = GetRoom().UserDefinedString1 }; json = JsonConvert.SerializeObject(userdefined_string_1); SendJsonToAllClients(json); break; case "userdefined_string_2": var userdefined_string_2 = new Json.SetValue() { type = "property_update", value_name = "userdefined_string_2", value = GetRoom().UserDefinedString2 }; json = JsonConvert.SerializeObject(userdefined_string_2); SendJsonToAllClients(json); break; case "userdefined_string_3": var userdefined_string_3 = new Json.SetValue() { type = "property_update", value_name = "userdefined_string_3", value = GetRoom().UserDefinedString3 }; json = JsonConvert.SerializeObject(userdefined_string_3); SendJsonToAllClients(json); break; case "room4th_temperature": var room4thTemp = new Json.SetValue() { type = "property_update", value_name = "room4th_temperature", value = GetRoom().Room4thTemperature }; json = JsonConvert.SerializeObject(room4thTemp); SendJsonToAllClients(json); break; case "room4th_presence_state": var room4thPresenceState = new Json.SetValue() { type = "property_update", value_name = "room4th_presence_state", value = GetRoom().Room4thPresenceState }; json = JsonConvert.SerializeObject(room4thPresenceState); SendJsonToAllClients(json); break; case "room4th_air_state": var room4thAirState = new Json.SetValue() { type = "property_update", value_name = "room4th_air_state", value = GetRoom().Room4thAirState }; json = JsonConvert.SerializeObject(room4thAirState); SendJsonToAllClients(json); break; case "room4th_light_state": var room4thLightState = new Json.SetValue() { type = "property_update", value_name = "room4th_light_state", value = GetRoom().Room4thLightState }; json = JsonConvert.SerializeObject(room4thLightState); SendJsonToAllClients(json); break; case "room4th_window_state": var room4thWindowState = new Json.SetValue() { type = "property_update", value_name = "room4th_window_state", value = GetRoom().Room4thWindowState }; json = JsonConvert.SerializeObject(room4thWindowState); SendJsonToAllClients(json); break; case "room4th_heater_state": var room4thHeaterState = new Json.SetValue() { type = "property_update", value_name = "room4th_heater_state", value = GetRoom().Room4thHeaterState }; json = JsonConvert.SerializeObject(room4thHeaterState); SendJsonToAllClients(json); break; case "room4th_blind_state": var room4thBlindState = new Json.SetValue() { type = "property_update", value_name = "room4th_blind_state", value = GetRoom().Room4thBlindState }; json = JsonConvert.SerializeObject(room4thBlindState); SendJsonToAllClients(json); break; case "room2nd_temperature": var room2ndTemp = new Json.SetValue() { type = "property_update", value_name = "room2nd_temperature", value = GetRoom().Room2ndTemperature }; json = JsonConvert.SerializeObject(room2ndTemp); SendJsonToAllClients(json); break; case "room2nd_presence_state": var room2ndPresenceState = new Json.SetValue() { type = "property_update", value_name = "room2nd_presence_state", value = GetRoom().Room2ndPresenceState }; json = JsonConvert.SerializeObject(room2ndPresenceState); SendJsonToAllClients(json); break; case "room2nd_air_state": var room2ndAirState = new Json.SetValue() { type = "property_update", value_name = "room2nd_air_state", value = GetRoom().Room2ndAirState }; json = JsonConvert.SerializeObject(room2ndAirState); SendJsonToAllClients(json); break; case "room2nd_light_state": var room2ndLightState = new Json.SetValue() { type = "property_update", value_name = "room2nd_light_state", value = GetRoom().Room2ndLightState }; json = JsonConvert.SerializeObject(room2ndLightState); SendJsonToAllClients(json); break; case "room2nd_window_state": var room2ndWindowState = new Json.SetValue() { type = "property_update", value_name = "room2nd_window_state", value = GetRoom().Room2ndWindowState }; json = JsonConvert.SerializeObject(room2ndWindowState); SendJsonToAllClients(json); break; case "room2nd_heater_state": var room2ndHeaterState = new Json.SetValue() { type = "property_update", value_name = "room2nd_heater_state", value = GetRoom().Room2ndHeaterState }; json = JsonConvert.SerializeObject(room2ndHeaterState); SendJsonToAllClients(json); break; case "room2nd_blind_state": var room2ndBlindState = new Json.SetValue() { type = "property_update", value_name = "room2nd_blind_state", value = GetRoom().Room2ndBlindState }; json = JsonConvert.SerializeObject(room2ndBlindState); SendJsonToAllClients(json); break; } }