package alamo import ( "encoding/json" "testing" "github.com/stretchr/testify/require" ) func TestReportedControlPreservesReadbackAndLocalHeatingMeaning(t *testing.T) { testCases := []struct { name string power bool active bool mode string action string }{ { name: "powered off has no heating action", mode: "off", action: "off", }, { name: "powered thermostat can be idle", power: true, mode: "heat", action: "idle", }, { name: "active thermostat reports local heating", power: true, active: true, mode: "heat", action: "heating", }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { state := testState() state.Power = tc.power state.Active = tc.active state.Locked = true reported := newReportedControl(state) require.Equal(t, tc.mode, reported.Settings.Mode) require.Equal(t, tc.action, reported.Action) data, err := json.Marshal(reported) require.NoError(t, err) require.Contains(t, string(data), `"current_temperature":19.5`) require.Contains(t, string(data), `"floor_temperature":23`) require.Contains(t, string(data), `"target_temperature":20`) require.Contains(t, string(data), `"locked":true`) }) } }