This repository has been archived on 2025-04-22. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
ha_client/lib/entity_class/switch_entity.class.dart
2018-10-01 21:57:54 +03:00

22 lines
489 B
Dart

part of '../main.dart';
class SwitchEntity extends Entity {
SwitchEntity(Map rawData) : super(rawData);
@override
void sendNewState(newValue) {
eventBus.fire(new ServiceCallEvent(
_domain, (newValue as bool) ? "turn_on" : "turn_off", entityId, null));
}
@override
Widget _buildActionWidget(bool inCard, BuildContext context) {
return Switch(
value: this.isOn,
onChanged: ((switchState) {
sendNewState(switchState);
}),
);
}
}