Skip to content

Commit b710d04

Browse files
andigclaude
andcommitted
Return ErrNotSupported when the remote does not advertise Write()
The Hvac and Setpoint write helpers issued a write command without checking whether the remote server feature advertises the Write() operation for the corresponding function. Guard each write helper so it returns api.ErrNotSupported unless the remote advertises Write(), matching the existing LoadControl/DeviceConfiguration behaviour. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9306bd3 commit b710d04

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

features/client/hvac.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ func (h *Hvac) WriteHvacOverrunListData(
9999
return nil, api.ErrMissingData
100100
}
101101

102+
// the remote server has to advertise the write operation for this function
103+
operation := h.featureRemote.Operations()[model.FunctionTypeHvacOverrunListData]
104+
if operation == nil || !operation.Write() {
105+
return nil, api.ErrNotSupported
106+
}
107+
102108
cmd := model.CmdType{
103109
HvacOverrunListData: &model.HvacOverrunListDataType{
104110
HvacOverrunData: data,
@@ -117,6 +123,12 @@ func (h *Hvac) WriteHvacSystemFunctionListData(
117123
return nil, api.ErrMissingData
118124
}
119125

126+
// the remote server has to advertise the write operation for this function
127+
operation := h.featureRemote.Operations()[model.FunctionTypeHvacSystemFunctionListData]
128+
if operation == nil || !operation.Write() {
129+
return nil, api.ErrNotSupported
130+
}
131+
120132
cmd := model.CmdType{
121133
HvacSystemFunctionListData: &model.HvacSystemFunctionListDataType{
122134
HvacSystemFunctionData: data,

features/client/setpoint.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ func (s *Setpoint) WriteSetpointListData(
6767
return nil, api.ErrMissingData
6868
}
6969

70+
// the remote server has to advertise the write operation for this function
71+
operation := s.featureRemote.Operations()[model.FunctionTypeSetpointListData]
72+
if operation == nil || !operation.Write() {
73+
return nil, api.ErrNotSupported
74+
}
75+
7076
cmd := model.CmdType{
7177
SetpointListData: &model.SetpointListDataType{
7278
SetpointData: data,

0 commit comments

Comments
 (0)