Jairzinno / hue_dart

A library for creating Philips Hue apps in Flutter and/or AngularDart.
Other
28 stars 12 forks source link

Deserializing failed: TypeCast Errors #5

Open Nekanu opened 4 years ago

Nekanu commented 4 years ago

Hi, I am currently trying to program a personal Philips Hue App and I love this library so far.

But I have two Problems: I am facing following error whenever I want to get any of these Items:

This Error has been thrown while calling bridge.rules() and I do get similar errors while calling one of the other functions:

E/flutter (18801): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Deserializing '[name, Dimmer Switch 4 on0, owner, e608140d-2baa-4ba4-8d4a-86e60418fe3b, crea...' to 'Rule' failed due to: Deserializing '[{address: /groups/3/action, method: PUT, body: {on: true}}, {address: /senso...' to 'BuiltList<RuleAction>' failed due to: Deserializing '[address, /groups/3/action, method, PUT, body, {on: true}]' to 'RuleAction' failed due to: Deserializing '[on, true]' to 'BuiltMap<String, String>' failed due to: Deserializing 'true' to 'String' failed due to: type 'bool' is not a subtype of type 'String' in type cast
E/flutter (18801): #0      BuiltJsonSerializers._deserialize (package:built_value/src/built_json_serializers.dart:154:11)
E/flutter (18801): #1      BuiltJsonSerializers.deserialize (package:built_value/src/built_json_serializers.dart:105:18)
E/flutter (18801): #2      BuiltJsonSerializers.deserializeWith (package:built_value/src/built_json_serializers.dart:36:12)
E/flutter (18801): #3      new Rule.fromJson (package:hue_dart/src/rule/rule.dart:61:10)
E/flutter (18801): #4      RuleApi._responseToRules (package:hue_dart/src/rule/rule_api.dart:25:25)
E/flutter (18801): #5      RuleApi.all (package:hue_dart/src/rule/rule_api.dart:18:12)
E/flutter (18801): <asynchronous suspension>
E/flutter (18801): #6      Bridge.rules (package:hue_dart/src/core/bridge.dart:146:54)
E/flutter (18801): #7      _RulesOverviewScreenState.didChangeDependencies (package:huepersonal/screens/rules/rulesOverviewScreen.dart:27:34)
E/flutter (18801): #8      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4661:12)
...

Following is the code where I call the function:

rules = await MyApp.bridge.rules().then((v) {
        print("Rules returned");
        setState(() {
          _isLoading = false;
        });
        return v;
      });

Flutter doctor:

[√] Flutter (Channel beta, v1.17.0-3.2.pre, on Microsoft Windows [Version 10.0.18363.815], locale en-DE)
    • Flutter version 1.17.0-3.2.pre at C:\Users\joshu\AppData\Roaming\flutter
    • Framework revision 2a7bc389f2 (6 days ago), 2020-04-21 20:34:20 -0700
    • Engine revision 4c8c31f591
    • Dart version 2.8.0 (build 2.8.0-dev.20.10)

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at C:\Users\joshu\AppData\Local\Android\Sdk
    • Platform android-29, build-tools 29.0.3
    • ANDROID_HOME = C:\Users\joshu\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    X Android license status unknown.
      Try re-installing or updating your Android SDK Manager.
      See https://developer.android.com/studio/#downloads or visit visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.

[√] Android Studio (version 3.6)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] IntelliJ IDEA Ultimate Edition (version 2019.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2019.2.3
    • Flutter plugin version 44.0.3
    • Dart plugin version 193.6494.35

[√] VS Code (version 1.44.2)
    • VS Code at C:\Users\joshu\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.9.1

[√] Connected device (1 available)
    • SM G973F • R38MB08VX0A • android-arm64 • Android 10 (API 29)

! Doctor found issues in 1 category.

I did also test it with Flutter 1.12.13+hotfix.8-stable

This library works so far for lights, groups and config. [I didn't test resourcelinks yet] I have used version 0.1.2 of this library and this did work there, but the lights were acting weird when ever I updated the state [Flashing, color changes]. I have only recently started programming with flutter and I don't know how that could be fixed.

Furthermore: I don't know if your code or the serializers are doing the following: -> The letter "ß" is not displayed properly: 20200428_221508 1 I checked the API and it returns the letter properly.

"6": {
        "name": "Außen",
        "lights": [
            "15"
        ],
          ...

Any help is appreciated. Nekanu

guyluz11 commented 1 year ago

Hi @Nekanu

Not sure if that will help you but I am working on adding Philips Hue control to the open-source smart home project that I am building.

It is named CyBear Jinni and it lets you control different smart devices from a single app. Feel free to join the discord server if you want to get updated when I am adding the Philips Hue support, or even join me and we will work on it together :D.

You can test my fork of the package, it probably will not fix your issue but it is worth trying.

Discord