Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Homebridge 2.0 #301

Open
rionshin opened this issue Jul 22, 2024 · 5 comments
Open

Support for Homebridge 2.0 #301

rionshin opened this issue Jul 22, 2024 · 5 comments
Assignees

Comments

@rionshin
Copy link

Soon Homebridge 2.0 will be released which will have some break changes to plugins.
could you please check is this plugin is impacted and make it working with 2.0

https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0

@jonad2002
Copy link

Testing with 2.0 B11 results:

[8/10/2024, 1:30:09 PM][homebridge-weather-plus]Adding station with weather service OpenWeatherMap named 'Home'
/var/lib/homebridge/node_modules/homebridge-weather-plus/util/characteristics.js:173
Characteristic.call(this, 'Air Pressure', CustomUUID.AirPressure);
^
TypeError: Class constructor Characteristic cannot be invoked without 'new'
at new CustomCharacteristic.AirPressure (/var/lib/homebridge/node_modules/homebridge-weather-plus/util/characteristics.js:173:18)
at TemperatureSensor.addCharacteristic (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Service.ts:518:57)
at /var/lib/homebridge/node_modules/homebridge-weather-plus/accessories/currentConditions.js:140:35
at Array.forEach ()
at new CurrentConditionsWeatherAccessory (/var/lib/homebridge/node_modules/homebridge-weather-plus/accessories/currentConditions.js:68:61)
at /var/lib/homebridge/node_modules/homebridge-weather-plus/index.js:94:30
at Array.forEach ()
at new WeatherPlusPlatform (/var/lib/homebridge/node_modules/homebridge-weather-plus/index.js:65:22)
at ChildBridgeFork.startBridge (/var/lib/homebridge/node_modules/homebridge/src/childBridgeFork.ts:155:42)

@fubu2k
Copy link

fubu2k commented Sep 18, 2024

Same error in Homebridge 2.0 beta 21. The Plugin needs an update.

@dacarson
Copy link
Collaborator

dacarson commented Dec 4, 2024

I am starting to look at this now.
It is probably also a good time to address: #150 Move off deprecated 'request' module

@dacarson dacarson self-assigned this Dec 4, 2024
@dacarson
Copy link
Collaborator

dacarson commented Dec 6, 2024

Landed fixes for #150. Can now look at Homebridge 2.0

dacarson added a commit that referenced this issue Dec 8, 2024
#301 Initial fixes to make the plugin work with Homebridge 2.0
Two basic changes:
1. Use of enums off the Characteristic class is no longer supported:
Instead of const Units = Characteristic.Units; you will need to use const Units = api.hap.Units;
Instead of const Formats = Characteristic.Formats; you will need to use const Formats = api.hap.Formats;
Instead of const Perms = Characteristic.Perms; you will need to use const Perms = api.hap.Perms;

2. Change custom characteristics to be classes with constructors, rather than using the inherits() functionality.
@dacarson
Copy link
Collaborator

dacarson commented Dec 9, 2024

With current checked in code, it is working but I get these errors:

HAP-NodeJS WARNING: The accessory 'Configured Name' has an invalid 'ConfiguredName' characteristic ('Wind Speed: 5.06 mph'). Please use only alphanumeric, space, and apostrophe characters. Ensure it starts and ends with an alphabetic or numeric character, and avoid emojis. This may prevent the accessory from being added in the Home App or cause unresponsiveness.
HAP-NodeJS WARNING: The accessory 'Configured Name' has an invalid 'ConfiguredName' characteristic ('Wind Dir: WNW'). Please use only alphanumeric, space, and apostrophe characters. Ensure it starts and ends with an alphabetic or numeric character, and avoid emojis. This may prevent the accessory from being added in the Home App or cause unresponsiveness.
HAP-NodeJS WARNING: The accessory 'Configured Name' has an invalid 'ConfiguredName' characteristic ('UV Index: null'). Please use only alphanumeric, space, and apostrophe characters. Ensure it starts and ends with an alphabetic or numeric character, and avoid emojis. This may prevent the accessory from being added in the Home App or cause unresponsiveness.
HAP-NodeJS WARNING: The accessory 'Configured Name' has an invalid 'ConfiguredName' characteristic ('Air Pressure: 1014.6 hPa'). Please use only alphanumeric, space, and apostrophe characters. Ensure it starts and ends with an alphabetic or numeric character, and avoid emojis. This may prevent the accessory from being added in the Home App or cause unresponsiveness.

I have filed a support ticket with Homebridge here homebridge/HAP-NodeJS#1079

dacarson added a commit that referenced this issue Dec 11, 2024
#301 Homekit has special rules for naming items. They must start with an alpha or numeric value, then they can contain alphanumeric characters, space and apostrophe, and they must end with an alpha or numeric character. The created sensors are using colons for delimiters, which isn't allowed. However, according to Apple documentation alphanumeric characters consist of Unicode character sets L*, M* and N*. The Modifier Letter Triangular Colon falls into the L* set, so it should be legal to use.
See homebridge/HAP-NodeJS#1079 for more detail.
Danimal4326 pushed a commit to Danimal4326/homebridge-weather-plus that referenced this issue Dec 20, 2024
naofireblade#301 Initial fixes to make the plugin work with Homebridge 2.0
Two basic changes:
1. Use of enums off the Characteristic class is no longer supported:
Instead of const Units = Characteristic.Units; you will need to use const Units = api.hap.Units;
Instead of const Formats = Characteristic.Formats; you will need to use const Formats = api.hap.Formats;
Instead of const Perms = Characteristic.Perms; you will need to use const Perms = api.hap.Perms;

2. Change custom characteristics to be classes with constructors, rather than using the inherits() functionality.
Danimal4326 pushed a commit to Danimal4326/homebridge-weather-plus that referenced this issue Dec 20, 2024
naofireblade#301 Homekit has special rules for naming items. They must start with an alpha or numeric value, then they can contain alphanumeric characters, space and apostrophe, and they must end with an alpha or numeric character. The created sensors are using colons for delimiters, which isn't allowed. However, according to Apple documentation alphanumeric characters consist of Unicode character sets L*, M* and N*. The Modifier Letter Triangular Colon falls into the L* set, so it should be legal to use.
See homebridge/HAP-NodeJS#1079 for more detail.
Danimal4326 added a commit to Danimal4326/homebridge-weather-plus that referenced this issue Dec 20, 2024
* Fix threshold triggers

naofireblade#296  Fix issue with threshold triggers and WeatherUnderground. In 3.3.4, WeatherUnderground API call was modified and incorrectly return values in km, and km/h

* Fix punycode warning

naofireblade#303 Fix punycode warning. Used fix recommended in mathiasbynens/punycode.js#137

* Fix util._extend warning

Fix naofireblade#303  Though I could not reproduce the warning, this should fix it.

* Migrate off request package

naofireblade#150  Migrate off the deprecated request package and moved all URL loads to using the supported axios package. Tried to make as smaller changes as possible.
Added a little more failure logging to enable better debugging.

Found that punycode was only being used by request so I could remove the work around for it (naofireblade#303)
Found that debug package wasn't explicitly being listed as a dependency in package.json, though index.js requires it, so added that.

Tested with valid tokens - all worked (only tested openweathermap 2.5 API)
Tested with invalid tokens - got correct error messages, didn’t crash HomeBridge
Tested with bad URLs - got correct error messages, didn’t crash HomeBridge

Migrated weewx weather station, though I wasn’t able to test it.

* Update CHANGELOG.md

naofireblade#150 Update Changelog

* Changes for Homebridge 2.0

naofireblade#301 Initial fixes to make the plugin work with Homebridge 2.0
Two basic changes:
1. Use of enums off the Characteristic class is no longer supported:
Instead of const Units = Characteristic.Units; you will need to use const Units = api.hap.Units;
Instead of const Formats = Characteristic.Formats; you will need to use const Formats = api.hap.Formats;
Instead of const Perms = Characteristic.Perms; you will need to use const Perms = api.hap.Perms;

2. Change custom characteristics to be classes with constructors, rather than using the inherits() functionality.

* Change colons for Modifier Letter Triangular Colon

naofireblade#301 Homekit has special rules for naming items. They must start with an alpha or numeric value, then they can contain alphanumeric characters, space and apostrophe, and they must end with an alpha or numeric character. The created sensors are using colons for delimiters, which isn't allowed. However, according to Apple documentation alphanumeric characters consist of Unicode character sets L*, M* and N*. The Modifier Letter Triangular Colon falls into the L* set, so it should be legal to use.
See homebridge/HAP-NodeJS#1079 for more detail.

---------

Co-authored-by: dacarson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants