Comments (9)
My Code:
package com.company;
import java.net.URLEncoder;
import io.github.zeroone3010.yahueapi.;
import io.github.zeroone3010.yahueapi.discovery.;
import io.github.zeroone3010.yahueapi.Color;
public class Main {
public static void main(String[] args) {
// Define IP & API UserName
final String bridgeIp = "(Filled In the Code)";
final String apiKey = "(Filled In the Code)";
// Define Hue Bridge (1st Bridge) & Define Room Affected
final Hue hue = new Hue(bridgeIp, apiKey);
final Room room = hue.getRoomByName("Filled in code").get();
// Change State
room.setState(State.builder().color(Color.of(java.awt.Color.PINK)).on());
}
}
Full Errors:
Exception in thread "main" io.github.zeroone3010.yahueapi.HueApiException: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of io.github.zeroone3010.yahueapi.domain.Root
out of START_ARRAY token
at [Source: (URL); line: 1, column: 1]
at io.github.zeroone3010.yahueapi.Hue.refresh(Hue.java:134)
at io.github.zeroone3010.yahueapi.Hue.doInitialDataLoadIfRequired(Hue.java:116)
at io.github.zeroone3010.yahueapi.Hue.getRoomByName(Hue.java:222)
at com.company.Main.main(Main.java:17)
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of io.github.zeroone3010.yahueapi.domain.Root
out of START_ARRAY token
at [Source: (URL); line: 1, column: 1]
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1468)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1242)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1190)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeFromArray(BeanDeserializer.java:604)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:190)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:166)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4526)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3399)
at io.github.zeroone3010.yahueapi.Hue.refresh(Hue.java:132)
... 3 more
- Sorry if I'm just being ignorant.
from yetanotherhueapi.
Hey, no problem! Are you using Bridge v1 (round) or Bridge v2 (square)? The error message is basically saying that the Bridge is responding with a message that the library cannot decode -- it's not of the expected format. This is why I suspect you might be using v1, as I've never actually tried this library with it, and unfortunately do not intend to support it either.
But let's see: can you access the API debug tool? In your browser, try navigating to http://<IP_ADDRESS_OF_YOUR_BRIDE>/debug/clip.html
You should be greeted with a form with the path "/api/1234/
" filled in. Replace "1234" with your API key, then GET
"/api/<YOUR_API_KEY>/groups
". The response should be something to this effect:
{
"1": {
"name": "Bedroom",
"lights": [
"1",
"3",
"4",
"2"
],
"sensors": [],
"type": "Room",
"state": {
"all_on": false,
"any_on": false
},
"recycle": false,
"class": "Bedroom",
"action": {
"on": false,
"bri": 1,
"hue": 10778,
"sat": 251,
"effect": "none",
"xy": [
0.5609,
0.4042
],
"ct": 443,
"alert": "select",
"colormode": "ct"
}
},
"2": {
"name": "Dining room",
"lights": [
"5"
],
"sensors": [],
"type": "Room",
"state": {
"all_on": true,
"any_on": true
},
"recycle": false,
"class": "Dining",
"action": {
"on": true,
"bri": 254,
"ct": 343,
"alert": "none",
"colormode": "ct"
}
}
}
i.e. the response begins with a curly bracket, {
. The error message you are getting indicates it would begin with a square bracket, [
. If it's not that, then please try what happens when you add /1
into the end of the path and GET
again. You should now get just the first room object, starting with the curly bracket.
from yetanotherhueapi.
Hi, thanks for the response I've accessed the API debugger:
{
"1": {
"name": "Lounge",
"lights": [
"3",
"7",
"22",
"21",
"2",
"4"
],
"sensors": [],
"type": "Room",
"state": {
"all_on": false,
"any_on": false
},
"recycle": false,
"class": "Living room",
"action": {
"on": false,
"bri": 144,
"hue": 7676,
"sat": 199,
"effect": "none",
"xy": [
0.5016,
0.4151
],
"ct": 443,
"alert": "lselect",
"colormode": "xy"
}
},
(Response for the first light only)
It seems to start with a brace as you implied
from yetanotherhueapi.
Also The Bridge I used is square with rounded edges, in-case that helps
from yetanotherhueapi.
Ahh you know what, I managed to replicate your issue. It happens when your API key is wrong, the response from the API is like this:
[
{
"error": {
"type": 1,
"address": "/",
"description": "unauthorized user"
}
}
]
so it starts with a [
and cannot be deserialized. Could you please double-check your code so that you haven't made any copy-paste errors, like including a leading or trailing space, or leaving one letter out from one end or the other?
from yetanotherhueapi.
I have just checked both the IP and APIkey are working, the IP I have checked through the app and the API key works when pasted into the URL: on the debugger; im not terribly sure what is happening.
from yetanotherhueapi.
Oh my goodness, I am so stupid. So there are two bridges on the network and I was using the wrong bridge which had no such name. So It works, thank you so much for time; I wish you the best of luck with your further endeavours :)
from yetanotherhueapi.
OK, good that you figured it out! 😄 I'll definitely have to think about making the error messages more informative in this case, so thank you for bringing this issue to my attention! 👍
from yetanotherhueapi.
This error handling improvement has now been released in version 2.2.0. ✅
from yetanotherhueapi.
Related Issues (20)
- Add colorloop effect
- Add group 0, i.e. the "all lights" group
- NPE when bridge doesn't return sensors HOT 5
- could you make a java 11 version which includes a module-info file. THX HOT 2
- Get color of light HOT 1
- Turn on / off room without setState (color, alert, etc...) HOT 2
- Why so restrictive? HOT 7
- Add mDNS support for discovering bridges HOT 1
- Add new light HOT 6
- Server-Sent Events HOT 7
- Implement a findByUiniqueId for lights and sensors HOT 11
- No logging by default HOT 3
- TemperatureSensor#getDegreesCelsius NPE HOT 10
- Get state ... question ? HOT 3
- Why such a restrictive State.Builder? HOT 2
- EffectType from String "prism": not one of the values accepted for Enum HOT 2
- Error when using v2 HOT 2
- JKS not found and java.io.FileNotFoundException: https://discovery.meethue.com/ HOT 28
- Client code generation HOT 2
- save bridge details HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yetanotherhueapi.