bombadiltom / homebridge-rademacher-homepilot

MIT License
26 stars 21 forks source link

Sun sensor not supported #45

Closed SnoopyCoder closed 4 years ago

SnoopyCoder commented 4 years ago

For the environment sensor accessory the ID 32000069 seems to be missing which is recognized for my sun sensor device and is reported as unknown product during initialization.

The code in index.js should probably be changed (in 2 places) from

// enviroment sensor
else if(["32000064","32000064_A","32000064_S"].includes(data.deviceNumber))
{
    ...
}

to

// enviroment sensor
else if(["32000064","32000064_A","32000064_S","32000069"].includes(data.deviceNumber))
{
    ...
}

Here is the full device info from the Homebridge logs:

[4/3/2020, 12:51:15] [RademacherHomePilot] {
  description: 'Sonnensensor',
  deviceGroup: 3,
  did: 1010017,
  automations: [ 30 ],
  readings: { sun_detected: false },
  batteryLow: false,
  timestamp: 1585840413,
  iconSetInverted: 0,
  iconSet: { k: 'iconset25' },
  name: 'Sonnensensor',
  statusValid: true,
  deviceNumber: '32000069',
  uid: 'a534dc_1',
  visible: true
}

Or is this a new device which requires a separate accessory implementation?

bombadiltom commented 4 years ago

did you test locally to add the device? do you have the other devices (temperature, lightsensor)?

SnoopyCoder commented 4 years ago

No, don‘t have these other devices. Just checked why my device is not showing up and found in the logs that the deviceNumber is not known.

Can I just patch a locally built version of the plugin into Homebridge? Didn‘t do this before. Then I could test it.

bombadiltom commented 4 years ago

have a look at deploy.sh

SnoopyCoder commented 4 years ago

Bildschirmfoto 2020-04-03 um 18 13 58

It looks good (see screenshot). There is no sun at the moment, I will test it tomorrow. But it was recognized during startup and shows up in the dashboard.

Apr  3 18:10:37 raspberrypi homebridge[23477]: [4/3/2020, 18:10:37] [RademacherHomePilot] Found environment sensor: Sonnensensor - Sonnensensor [1010017]
Apr  3 18:10:37 raspberrypi homebridge[23477]: [4/3/2020, 18:10:37] [RademacherHomePilot] no position in blind object {
Apr  3 18:10:37 raspberrypi homebridge[23477]:   description: 'Sonnensensor',
Apr  3 18:10:37 raspberrypi homebridge[23477]:   deviceGroup: 3,
Apr  3 18:10:37 raspberrypi homebridge[23477]:   did: 1010017,
Apr  3 18:10:37 raspberrypi homebridge[23477]:   automations: [ 30, [length]: 1 ],
Apr  3 18:10:37 raspberrypi homebridge[23477]:   readings: { sun_detected: false },
Apr  3 18:10:37 raspberrypi homebridge[23477]:   batteryLow: false,
Apr  3 18:10:37 raspberrypi homebridge[23477]:   timestamp: 1585840413,
Apr  3 18:10:37 raspberrypi homebridge[23477]:   iconSetInverted: 0,
Apr  3 18:10:37 raspberrypi homebridge[23477]:   iconSet: { k: 'iconset25' },
Apr  3 18:10:37 raspberrypi homebridge[23477]:   name: 'Sonnensensor',
Apr  3 18:10:37 raspberrypi homebridge[23477]:   statusValid: true,
Apr  3 18:10:37 raspberrypi homebridge[23477]:   deviceNumber: '32000069',
Apr  3 18:10:37 raspberrypi homebridge[23477]:   uid: 'a534dc_1',
Apr  3 18:10:37 raspberrypi homebridge[23477]:   visible: true
Apr  3 18:10:37 raspberrypi homebridge[23477]: }
Apr  3 18:10:37 raspberrypi homebridge[23477]: [4/3/2020, 18:10:37] [RademacherHomePilot] Added environment sensor: Sonnensensor - Sonnensensor [1010017]
bombadiltom commented 4 years ago

yeah, it only supports sun_detected: true and false, unfortunately, a new accessory class would be needed for this

bombadiltom commented 4 years ago

the environment sensor uses sun_brightness between 0 and 100

bombadiltom commented 4 years ago

also the real environment sensor inherits from blinds accesory:

function RademacherEnvironmentSensorAccessory(log, accessory, sensor, session, inverted) { RademacherBlindsAccessory.call(this, log, accessory, sensor, session, inverted);

this is why "no position in blind object" occurs

SnoopyCoder commented 4 years ago

This is the device.

https://www.amazon.de/gp/product/B0085IGE86/

In HomeKit it also doesn't show any values. So I guess you are right and a new accessory class is needed.

SnoopyCoder commented 4 years ago

Any chance somebody of you contributors develop this in the next weeks? If not, which example should I use as starting point to do it myself? Will I be allowed to create a pull request then?

bombadiltom commented 4 years ago

just copy the class for environment sensor, delete the blinds and temperature stuff and translate sun_detected=true to 100 and sun_detected=false to 0 PR should be possible, just create a feature branch if you have any problems: just ask

SnoopyCoder commented 4 years ago

I have it working as lightbulb, but I was not able to implement it as ambient light sensor so that it can be used as sensor to trigger an automation in HomeKit. Need to figure this out. Any hint what’s is needed to make an accessory with just an ambient light service usable as sensor in HomeKit?

SnoopyCoder commented 4 years ago

Ok, I have found out, that the HomeKit LightSensor service doesn't support triggering for AmbientLightLevel yet. The only way to support triggering as well as using as condition in an automation is to implement both LightSensor and Switch services which are combined into one then again in HomeKit. The trigger capability is then available as normal switch device which is turning on automatically when strong sun light is detected.

For me this is perfectly working now although it is not ideal to have the sun as a light switch.

Do you want me to submit this implementation as pull request or keep it private. There seems to be no other way at the moment to support this sun sensor device.

bombadiltom commented 4 years ago

In HomeKit Sensors don't trigger anything, this is always done by an automation. So, if you have a sensor class running that reflects Sunlight on and off, feel free to file a PR

SnoopyCoder commented 4 years ago

Ok, will do.

The problem is that when I create a new automation in HomeKit and select “sensor” as trigger, then the sun sensor is not appearing. This is known to be a limitation with LightSensor service in HomeKit today.

But one can use it as a condition in an automation (e.g. only take action on another trigger event if the sun sensor light level has certain value).

Additionally, because I have implemented an addition Switch service for the same accessory one can use the switch on/off events as trigger. The Switch is automatically turning on when sun was detected.

I will push the branch and file a pull request. Then you can decide if you want to approve it.

SnoopyCoder commented 4 years ago

I'm not able to push my branch to the GitHub repo:

git push -u origin duofern9478 remote: Permission to bombadiltom/homebridge-rademacher-homepilot.git denied to SnoopyCoder. fatal: unable to access 'https://github.com/bombadiltom/homebridge-rademacher-homepilot.git/': The requested URL returned error: 403

Am I lacking some permissions?

bombadiltom commented 4 years ago

you cannot push to this repo directly, you need to fork it and create the pr from the fork

bombadiltom commented 4 years ago

regarding automation have a look at https://github.com/QuickSander/homebridge-http-ambient-light-sensor

I think here you need a timer which pulls the status periodically, because the homepilot does not allow to push the status (only by email, but that is too slow, isnt it?)

SnoopyCoder commented 4 years ago

Ah, ok. I have submitted a pull request now.

SnoopyCoder commented 4 years ago

Here is the link to the pull request: https://github.com/bombadiltom/homebridge-rademacher-homepilot/pull/46

bombadiltom commented 4 years ago

merged, thanks a lot