+ return messages
+}
+
+type cancelingGateway struct {
+ cancel context.CancelFunc
+ failure error
+}
+
+func (g *cancelingGateway) Status(_ context.Context) ([]State, error) {
+ g.cancel()
+
+ return nil, errors.Join(context.Canceled, g.failure)
+}
+
+func (g *cancelingGateway) Action(_ context.Context, _ string, _ Action) (State, error) {
+ g.cancel()
+
+ return State{}, errors.Join(context.Canceled, g.failure)
+}
+
+func testDriver(t *testing.T, client Client, transport *fakeTransport, thermostats ...Thermostat) (*Driver, *driver.Router) {
+ t.Helper()
+
+ if len(thermostats) == 0 {
+ thermostats = []Thermostat{{
+ DeviceID: testDeviceID,
+ MAC: testMAC,
+ }}
+ }
+
+ var ids []string
+
+ for _, thermostat := range thermostats {
+ ids = append(ids, thermostat.DeviceID)
+ }
+
+ router, err := driver.NewRouter(ids)
+ require.NoError(t, err)
+
+ integration, err := New(Settings{Thermostats: thermostats}, driver.NewPublisher(transport), router, client)
+ require.NoError(t, err)
+
+ return integration, router
+}
+
+func testCommand() driver.Command {
+ expires := time.Now().Add(time.Minute).UTC()
+
+ return driver.Command{
+ DeviceID: testDeviceID,
+ Capability: "control",
+ Metadata: protocol.Metadata{
+ MessageID: testCommandID,
+ ExpiresAt: &expires,
+ },
+ Payload: protocol.ValuePayload{Value: []byte(`{"mode":"heat","target_temperature":22}`)},
+ }