Code Monkey home page Code Monkey logo

echonetlitewebapiclient's Introduction

EchonetLiteWebAPIClient

A ECHONET Lite Web API Client written for dart

This client implements the ECHONET Lite Web API Guideline version 1.1.4. The client is an http client that supports parsing JSON results replied from a ECHONET Lite Web API server into dart objects. The current version supports all devices defined in the Device Description v1.4.0.

Features

  • Get a list of device (abstracted information only) that is currently available at the Web API server
final  RegisteredDeviceList  devList = await  client.getRegisteredDevices();

for (final  Profile  profile  in  devList.profiles) {
	print(profile.toJson());
}
	
  • Fetch a list of device resources
final  List<EchonetLiteDevice>? devices =
await  client.fetchRegisteredDevicesResources(devList);
if (devices != null) {
	for (final  EchonetLiteDevice  dev  in  devices) {
		if (dev.runtimeType == TemperatureSensor) {
			final  TemperatureSensor  temperatureSensor = dev  as  TemperatureSensor;
			print(temperatureSensor.toJson());
		}
	}
}
  • Get device resources by type
final  List<EchonetLiteDevice>? temperatureSensors =
await  client.getDeviceResourcesByType(DeviceType.temperatureSensor, null);
if (temperatureSensors != null) {
   for (final  EchonetLiteDevice  sensor  in  temperatureSensors) {
   final  TemperatureSensor  temperatureSensor = sensor  as  TemperatureSensor;
   print(temperatureSensor.toJson());
   }
}
final  TemperatureSensor  sensor =
await  client.getTemperatureSensor('temperatureSensor1653899075894947');
print(sensor.toJson());
  • Set a device with pair of {property: value}
bool  setResult = await  client.setOperationStatus('generalLighting1653899076208582', false);
// Or
bool  setResult2 = await  client.setPropertyNameWithValue('generalLighting1653899076208582','operationStatus', false);

Supported devices

  • airCleaner
  • airConditionerVentilationFan
  • bathHeatingStatusSensor
  • bathroomHeaterDryer
  • co2Sensor
  • coldOrHotWaterHeatSourceEquipment
  • commercialAirConditionerIndoorUnit
  • commercialAirConditionerOutdoorUnit
  • commercialShowcase
  • commercialShowcaseOutdoorUnit
  • controller
  • cookingHeater
  • currentSensor
  • electricEnergySensor
  • electricLock
  • electricRainDoor
  • electricWaterHeater
  • emergencyButton
  • enhancedLightingSystem
  • evCharger
  • evChargerDischarger
  • floorHeater
  • fuelCell
  • gasMeter
  • generalLighting
  • homeAirConditioner
  • humanDetectionSensor
  • humiditySensor
  • hvSmartElectricEnergyMeter
  • hybridWaterHeater
  • illuminanceSensor
  • instantaneousWaterHeater
  • lightingSystem
  • lvSmartElectricEnergyMeter
  • monoFunctionalLighting
  • powerDistributionBoardMetering
  • pvPowerGeneration
  • refrigerator
  • riceCooker
  • smartElectricEnergySubMeter
  • storageBattery
  • switch
  • temperatureSensor
  • tv
  • ventilationFan
  • vocSensor
  • washerDryer
  • waterFlowMeter
  • wattHourMeter

Usage

  • See /example folder
  • Refer to /test/mock_web_api_server/responses/all_properties/{deviceType}.json for reponses that will be returned from the ECHONET Lite Web API server
  • Refer to /test/mock_web_api_server/expectedResults/parsed_devices.dart for more usage examples.

Additional information

  • Json serialization and deserialization files {deviceType}.g.dart are auto-generated.
  • Typo mistakes were reported to the ECHONET Lite Web API Working group and will be corrected in the future release. Therefore, the coldOrHotWaterHeatSourceEquipment and instantaneousWaterHeater might not work with the current ECHONET Lite Web API server (v1.3.0).

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to provide tests as appropriate.

License

  • BSD 3, See LICENSE

echonetlitewebapiclient's People

Contributors

cupham avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.