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

Current Measurement device support? #141

Open
glennoky opened this issue Dec 23, 2023 · 29 comments
Open

Current Measurement device support? #141

glennoky opened this issue Dec 23, 2023 · 29 comments

Comments

@glennoky
Copy link

Hi All,

I'm a newbie to HomeBridge, an SAP ABAP coder by trade, have had C-Bus installed since 2006 and have played with many C-Gate consuming control tools over the years, but iOS Home using this plugin is the best so far. I have a shiny new Current Measurement Unit 5504CMU and am wanting to get it displaying in Home and while the existing Temperature accessory looks close to me, will this work without changes?

Thanks,
Glenn.

@JasonY00
Copy link
Contributor

JasonY00 commented Jan 9, 2024

Hi Glenn,

Homekit doesn't support Current Measurement, however, if you set your current measurement device up as temperature sensors in Homebridge, they will display just fine. I use this for my current measurement unit.

Any C-Bus measurement device including the C-Bus General I/O unit will work. Just remember to add the channel number as well. The current measurement unit has four channels. Some multi channel C-Bus measurement devices start at Channel 0 and some at Channel 1 so just make sure you choose the correct channel number.

Cheers

Jason

@glennoky
Copy link
Author

Hi Jason,

Thanks heaps for the response.

Since asking this question I did setup as you suggest. In who's hands would providing support be in?

Also, as I have three phase and don't care about the individual phases, is there a point between three CT's and HomeKit that will let me merge the three values into one Temperature Accessory?

Thanks again,
Glenn.

@JasonY00
Copy link
Contributor

JasonY00 commented Jan 10, 2024

Hi Glenn,
As far as support goes…there is none except for the goodwill of the development community. Pretty much everyone useful and interested in C-bus/homekit is here and in the cbusforums.com site. Many of us have contributed to integrating c-bus device support into the Homebridge-Cbus plugin. Ask for help and one of us can usually assist.

WRT to rolling the three phases of current sensors into a “total current” usage device, this isn’t something that is supported within the plugin and configuration of sensors. May I suggest investigating Node Red, that can be also run on the same pi as Homebridge. This has a HomeKit plugin where you can take the three measurements and add them using node red logic with a simple “add inputs” block. From here you could just create a “summed” current (temperature) sensor that will appear as a new sensor in HomeKit with a single summed value.

I am using node red to do things like this for garage door opener with open/closed reeds and obstruction sensors from cbus. I am travelling at the moment, but when back, I will have a look at it. In the meantime, have a look at node red. It is awesome!

Cheers

Jason

@JasonY00
Copy link
Contributor

JasonY00 commented Jan 17, 2024

Hi Glenn,

I am back from travelling and had time to mock up a single current sensor from the three phases. I have used Node Red to input three phases of the C-Bus Current Sensor defined as Temp sensors in Homekit. In Node Red, I just used a function to add them and output a single phase Temp (Current) Sensor. It looks complicated, but I left the green "Debug" boxes to show the values at each step. Below is the output in homekit. Note that as I took the screen capture from the phone and node red at different times, the values had changed. If you are wondering why the current is so high, my 22kW ducted AirCon unit is on. Each phase is usually about 3-4 amps...

image

zxc

So, it's doable, with a little bit of mucking around. Have a look at Node Red, it is very powerful. I can also help you in setting up something if you are interested.

I also used it to define homekit thermostats to manage temperatures in each room of my house with my "dumb" ducted AirCon. Each room has a zone damper controlled by a low voltage c-bus relay and c-bus temp sensor. Logic in my colour C-Touch screens manages the dampers and the desired temperatures can be set there or on the phone in homekit. It's well worth a look and is easily set up on the same pi as homebridge.

Cheers

Jason

@JasonY00
Copy link
Contributor

Hi Glenn,

can you close this issue if you think it’s resolved?

cheers

Jason

@glennoky
Copy link
Author

Hi Jason,

These may be purely electrical questions, but you may be able to answer them. As I have no need to keep the three phases separate, is it possible to merge via the wiring of the clamps? Will a single clamp fit all three wires? Or can three clamps be wired to one of the four circuits? This would allow me to monitor more circuits with the one device (E.g. Solar) and allow me to avoid going down the Rabbit Hole that Node-RED would be for me. :) Failing this you have been more than helpful and am happy to close this issue, I will just have to find the time to get Node-RED working and configured on the VM I have Homebridge running in. There was a time when this would have been fun, but I must be getting old. :)

Thanks,
Glenn.

@JasonY00
Copy link
Contributor

JasonY00 commented Jan 28, 2024

Hi Glenn,

Putting the three phases on one channel of the current measurement unit won’t work. The three power phases supplied to you are voltage sine waves that are 120 degrees out of phase with each other at 240V each relative to Neutral. The total 3 phase voltage is 415V between phases. In an ideal setup, the 3 phases are balanced w.r.t. their current loading and would cancel each other out. This is by design. This is never true in practice with each phase drawing different currents and with inductive or capacitive loads the current phases “move” a little bit from the phases of their corresponding voltages. This is what power factor is. You want the current and voltage of each phase the be as close as possible. Lots of theory on this so have a google of power factor correction. The supply authority does this correction at the substations with giant capacitor banks that they switch into and out of the supply at different times of the day when there is a large inductive load from electric motors.

Back to your problem. With the above in mind, if you have a balanced system and put all three phases onto the one clamp on your c-bus current measurement device, when you add the 3 current “vectors” you should ideally get a total current less than your lowest phase current! Hopefully almost 0Amps!

When you add each phase separately you are just adding their scalar values and ignoring their respective phases which is giving you a “true” total current draw. This is why you have 3 meters. If you had only one meter for your three phases, your bill would be pretty low. So you will have to do some sort of math somewhere to get the total current for the 3 phases. I suggested node-red for your problem for this reason and you can also make other complex devices in HomeKit using c-bus relays, sensors and dry-contact inputs.

The only other alternative is if you have some sort of c-bus logic unit on your network like a c-touch with logic, a PAC or the newer SHAC. You could then set up three current variables and add them there. But you would still need to then get them back to HomeKit somehow…

Not the answer you wanted, but now you know why…?

Cheers

Jason

@glennoky
Copy link
Author

Hi Jason,

I was after the facts and it sounds very much like you've provided them! Thanks heaps, Node-RED it is.

Thanks,
Glenn.

@JasonY00
Copy link
Contributor

Thanks Glenn,

if you set up node red, let me know and I will help you along with the plugins required and the flow for current measurement.

cheers

Jason

@glennoky
Copy link
Author

Hi Jason,

With Node-RED now installed and confronted with the editor, from your image it looks like you have re-coloured an "Inject" as the three "PhaseX Current"? As I believe this node should point at C-Gate somehow? Some further help here would be very much appreciated. :)

Thanks,
Glenn.

@glennoky glennoky reopened this Jan 28, 2024
@JasonY00
Copy link
Contributor

JasonY00 commented Jan 28, 2024

HI Glenn,

you have had a busy afternoon. If you have node-red up and running, make sure you install the following plugins:

node-red-contrib-homebridge-automation and
node-red-contrib-homekit-bridged

One will enable you to read homekit (originating from c-bus) inputs and the other will enable you to define homekit devices. i.e. read the c-bus temp(current) sensors defined in homekit into node-red, (do the math) and create a new temp(current) sensor for the summed three phases to display in homekit.

So they are not recoloured "inject nodes" but homekit input nodes.

My flow for this is below. Install the plugins and then import the flow. It will break, because you need to input your homebridge pin and load the appropriate homekit device.

image

the maths is done in the "combine Phases "function block" that uses global variables that are automatically read when c-bus broadcasts the temperatures over the network. Every 30 seconds, the function just adds the current values for the global variables and outputs it to the new "Total Current" homekit sensor

image

So paste the flow below into your node-red and change the pin for your homebridge installation, and your devies will hopefully appear. Change my 3 temp(current) inputs to yours and hopefully youo will be good to go. You will have to add a new bridge in homekit with the pin that you choose for your new temp sensor. In the example its 111-11-112 and as a hangover from another thing I was playing with, the bridge name is villa-test.

Cheers and let me know if you hit a wall...

Jason

Here is the flow to paste into node-red: Copy everything between the plus signs below!
+++++++++++++++++++++++++++++++++++++++++++++++++++++

[
{
"id": "f2fd338a852fdb45",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "fcd7105a5b2f91f0",
"type": "hb-event",
"z": "f2fd338a852fdb45",
"name": "Phase1 Current",
"Homebridge": "homebridge",
"Manufacturer": "Clipsal C-Bus",
"Service": "Temperature Sensor",
"device": "homebridge0E:79:E7:31:D6:64Clipsal C-BusPhase1 Current0000008A",
"conf": "a5ca22afc0b3dab0",
"sendInitialState": true,
"x": 460,
"y": 240,
"wires": [
[
"77c1b4c66ec652fa",
"cd0bc8906f9fbf32"
]
]
},
{
"id": "533f5d63a8eae69e",
"type": "hb-event",
"z": "f2fd338a852fdb45",
"name": "Phase2 Current",
"Homebridge": "homebridge",
"Manufacturer": "Clipsal C-Bus",
"Service": "Temperature Sensor",
"device": "homebridge0E:79:E7:31:D6:64Clipsal C-BusPhase2 Current0000008A",
"conf": "a5ca22afc0b3dab0",
"sendInitialState": true,
"x": 100,
"y": 400,
"wires": [
[
"d6480c1c4fe35bff",
"cd0bc8906f9fbf32"
]
]
},
{
"id": "c3fc1bff3495d8e8",
"type": "hb-event",
"z": "f2fd338a852fdb45",
"name": "Phase3 Current",
"Homebridge": "homebridge",
"Manufacturer": "Clipsal C-Bus",
"Service": "Temperature Sensor",
"device": "homebridge0E:79:E7:31:D6:64Clipsal C-BusPhase3 Current0000008A",
"conf": "a5ca22afc0b3dab0",
"sendInitialState": true,
"x": 460,
"y": 580,
"wires": [
[
"78d33bf4d86e2937",
"cd0bc8906f9fbf32"
]
]
},
{
"id": "ba569ab5eaa9b418",
"type": "homekit-service",
"z": "f2fd338a852fdb45",
"isParent": true,
"hostType": "0",
"bridge": "56f83ee1.f0bbd",
"accessoryId": "",
"parentService": "",
"name": "Total Current",
"serviceName": "TemperatureSensor",
"topic": "",
"filter": false,
"manufacturer": "NRCHKB",
"model": "1.5.0",
"serialNo": "Default Serial Number",
"firmwareRev": "1.5.0",
"hardwareRev": "1.5.0",
"softwareRev": "1.5.0",
"cameraConfigVideoProcessor": "ffmpeg",
"cameraConfigSource": "",
"cameraConfigStillImageSource": "",
"cameraConfigMaxStreams": 2,
"cameraConfigMaxWidth": 1280,
"cameraConfigMaxHeight": 720,
"cameraConfigMaxFPS": 10,
"cameraConfigMaxBitrate": 300,
"cameraConfigVideoCodec": "libx264",
"cameraConfigAudioCodec": "libfdk_aac",
"cameraConfigAudio": false,
"cameraConfigPacketSize": 1316,
"cameraConfigVerticalFlip": false,
"cameraConfigHorizontalFlip": false,
"cameraConfigMapVideo": "0:0",
"cameraConfigMapAudio": "0:1",
"cameraConfigVideoFilter": "scale=1280:720",
"cameraConfigAdditionalCommandLine": "-tune zerolatency",
"cameraConfigDebug": false,
"cameraConfigSnapshotOutput": "disabled",
"cameraConfigInterfaceName": "",
"characteristicProperties": "{}",
"waitForSetupMsg": false,
"outputs": 2,
"x": 1350,
"y": 400,
"wires": [
[],
[]
]
},
{
"id": "dcf9114d364a0fb5",
"type": "function",
"z": "f2fd338a852fdb45",
"name": "Combine Phases",
"func": "var Current = global.get("Current") || {}; // load "Current" or set to empty \nvar output = {};\nglobal.set("Current", Current);\n\nCurrent.TotalCurrent = 0;\n\nCurrent.TotalCurrent = Current.Phase1 + Current.Phase2 + Current.Phase3;\n\nmsg.payload.CurrentTemperature = Current.TotalCurrent;\n\noutput = {"payload": {"CurrentTemperature": Current.TotalCurrent}}\n \nreturn output",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1110,
"y": 400,
"wires": [
[
"ba569ab5eaa9b418",
"57d69de9be969e96"
]
]
},
{
"id": "57d69de9be969e96",
"type": "debug",
"z": "f2fd338a852fdb45",
"name": "Total Current",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 1360,
"y": 340,
"wires": []
},
{
"id": "cd0bc8906f9fbf32",
"type": "trigger",
"z": "f2fd338a852fdb45",
"name": "",
"op1": "",
"op2": "0",
"op1type": "date",
"op2type": "str",
"duration": "-30",
"extend": false,
"overrideDelay": false,
"units": "s",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 870,
"y": 400,
"wires": [
[
"dcf9114d364a0fb5"
]
]
},
{
"id": "77c1b4c66ec652fa",
"type": "change",
"z": "f2fd338a852fdb45",
"name": "Global Phase 1 Current",
"rules": [
{
"t": "set",
"p": "Current.Phase1",
"pt": "global",
"to": "payload.CurrentTemperature",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 730,
"y": 240,
"wires": [
[
"7230fe4660994442"
]
]
},
{
"id": "d6480c1c4fe35bff",
"type": "change",
"z": "f2fd338a852fdb45",
"name": "Global Phase 2 Current",
"rules": [
{
"t": "set",
"p": "Current.Phase2",
"pt": "global",
"to": "payload.CurrentTemperature",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 330,
"y": 440,
"wires": [
[
"f4f1c37de7c0d198"
]
]
},
{
"id": "78d33bf4d86e2937",
"type": "change",
"z": "f2fd338a852fdb45",
"name": "Global Phase 3 Current",
"rules": [
{
"t": "set",
"p": "Current.Phase3",
"pt": "global",
"to": "payload.CurrentTemperature",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 730,
"y": 580,
"wires": [
[
"a4ada6d14d3d3bed"
]
]
},
{
"id": "7230fe4660994442",
"type": "debug",
"z": "f2fd338a852fdb45",
"name": "Phase 1 Current",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 970,
"y": 240,
"wires": []
},
{
"id": "f4f1c37de7c0d198",
"type": "debug",
"z": "f2fd338a852fdb45",
"name": "Phase 2 Current",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 570,
"y": 440,
"wires": []
},
{
"id": "a4ada6d14d3d3bed",
"type": "debug",
"z": "f2fd338a852fdb45",
"name": "Phase 3 Current",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 970,
"y": 580,
"wires": []
},
{
"id": "011aed7102d77070",
"type": "inject",
"z": "f2fd338a852fdb45",
"name": "???",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{"foo":"bar"}",
"payloadType": "json",
"x": 1150,
"y": 460,
"wires": [
[
"ba569ab5eaa9b418"
]
]
},
{
"id": "a5ca22afc0b3dab0",
"type": "hb-conf",
"username": "031-45-154",
"macAddress": ""
},
{
"id": "56f83ee1.f0bbd",
"type": "homekit-bridge",
"bridgeName": "villa-test",
"pinCode": "111-11-112",
"port": "",
"allowInsecureRequest": false,
"manufacturer": "ptath",
"model": "raspberry pi zeroW",
"serialNo": "12345678",
"firmwareRev": "",
"hardwareRev": "",
"softwareRev": "",
"customMdnsConfig": false,
"mdnsMulticast": true,
"mdnsInterface": "",
"mdnsPort": "",
"mdnsIp": "",
"mdnsTtl": "",
"mdnsLoopback": true,
"mdnsReuseAddr": true,
"allowMessagePassthrough": true
}
]
+++++++++++++++++++++++++++++++++++++++++++

@JasonY00
Copy link
Contributor

JasonY00 commented Jan 28, 2024

oh! by the way, if you are wondering what the little grey "???" inject node is, when you send the JSON payload of {"foo":"bar"} to the homekit output node it tells you what parameters the accessory supports. This is the output:

Instead of 'foo' try one of these characteristics: 'Name', 'CurrentTemperature', 'StatusActive', 'StatusFault', 'StatusLowBattery', 'StatusTampered'

So you know what the supported Characteristics are in homekit for the Temperature Sensor Service as you see above. Go here for all of the allowed values the corresponding characteristics:

https://github.com/homebridge/HAP-NodeJS/blob/b34cc46ec4606fb0c56e0f642fc1bfc2fb255bd5/src/lib/definitions/CharacteristicDefinitions.ts

and here for the Homekit Services:

https://github.com/homebridge/HAP-NodeJS/blob/b34cc46ec4606fb0c56e0f642fc1bfc2fb255bd5/src/lib/definitions/ServiceDefinitions.ts

They are from the HAP-NodeJS Github site that underpins Homebridge: https://github.com/homebridge/HAP-NodeJS

Have fun.

Jason

@glennoky
Copy link
Author

Hi Jason,

Thanks heaps for the help. If I've learnt anything so far, it is that I have HEAPS to learn in this context. I still don't have a clear picture of the roles of each of the pieces of the puzzle I've hit so far, but I'm happy for this to be a work in progress.

Issues and Learnings...

  • Hadn't used npm before (mostly apt-get?), learnt the hard way it cares about your current directory!
  • The "Import" complained about two levels of double quotes. Changed lower quoting from global.get("Current") to global.get('Current') to get around it. I think! Looks like some contexts are ok with this, but others not.
  • Took me awhile to find/remember where the Homebridge Pin lived!

So I have the plugins installed and your flow imported and I'm attempting to update things to point at my setup.
When I update "hb-config" and "homekit-bridge" with my details (including MAC and Port), I see two exclamation marks and things like "Devices" aren't seen.

image

Is the fact I have Node-RED running on a Pi but Homebridge running as an image in a Windows VM complicating things for me?

Thanks,
Glenn.

@JasonY00
Copy link
Contributor

JasonY00 commented Jan 30, 2024

Hi Glenn,

It sounds like you are getting there. I must say that my own experience with Node-Red is still at a lower level, but it is amazing what it can do and the plugin library is immense!

Just a heads up regarding the homebridge plugins:

image

node-red-contrib-homebridge-automation: This plugin is for "talking to" your existing homebridge installation. These are hb-event nodes dragged across from the Homebridge nodes in the left panel. You get your pin from your current homebridge installation (easy to read it from your homebridge-UI) and put into the EVENT nodes that you place into the flow. These are the "PhaseX Current" nodes. So in your case, you will need to change my old homebridge pin and put yours in. All of your homebridge defined devices should appear in a drop down list after node-red finds your homebridge. If you get this bit working, you are nearly done! This is the critical bit, so spend some time trying to get it going...If you get this up and running, you can then do anything in Node-Red with your homebridge data including changing it!

node-red-contrib-homekit-bridged: This plugin creates a new homekit bridge accessory within Node Red that can be added to homekit in your iOS device. I just dragged a "Service Node" from the Apple Homekit nodes on the left panel. Clicked on it to configure it and chose TemperatureSensor as the service. It has it's own bridge name(villa-test) and pin(111-11-112). When configuring, click on the pencil icon next to the bridge name to open another window to add or change the pin. You can just leave what I had to get everything started or change it to something more useful. I didn't bother...). This part has nothing to do with your existing homebridge installation! It is added in homekit on your iphone/ipad and you just add a new accessory and choose to put the pin in just like you would if you purchased a homekit compatible device.

image

image

Now, my flow above has done all of this for you except you will have to change the PIN for the three input phases, select the three sensors you have already defined in your homebridge-cbus config and add the "Total current" accessory to your phone using the separate PIN as above.

Effectively you now have your "homebridge" accessory already in your homekit displaying the three seperate phase currents and now you also have a "node-red" total phase current accessory in your homekit. Node-red just reads the current values for the three phases from the homebridge accessory, does some mathemagic and writes the value to your node-red accessory.

Hopefully this helps get you there...let me know if you hit another snag or if you get it going...

Cheers

Jason

@glennoky
Copy link
Author

Hi Jason,

I think I'm now as far as I can go, without getting my electrician to install the Sensor for me. I baulked at the wiring needing a "Shorting block" from even testing the thing. I'm not an electrician and have no idea what one is! :)

But I have Node-RED now seeing Homebridge, by ditching my VM and installing it on the same Pi. And the flow seems relatively happy and delployed, but the "hb-event" nodes have a status of "Disconnected"...

image

Any other way to check I have things right, without numbers coming from the sensor?

Thanks,
Glenn.

@JasonY00
Copy link
Contributor

JasonY00 commented Jan 31, 2024

Try another device from homebridge. It doesn't matter if it errors further along the flow. You just want to see something coming in from your homebridge to Node-Red. Try a dimmer group address in your "Shed Phase 1" node just to test the link. Or drop another homebridge node in as a dimmer. If it still doesn't work, then we have more work to do...

For example, if you set the Shed Phase1 input to a group address of a Dimmer, you should see something like this:

image

A "node-red-stop" & "node-red-start" on the pi may be useful if you don't have any luck...

You can also just connect the current sensor into your cbus network and have it running with the current sensors attached but not "clamped" across your active phases. You will just get a value of 0.00A on each channel. My Current Measurement Unit is just mounted in my main switchboard and the current clamps are clipped around the phases on my side of the main switch like the installation instructions:

image

No shorting block...

If you are worried, then just clip it around an appliance lead of something, i.e. laptop, lamp etc.

Have you defined the Current Sensor configuration in the Toolkit database and Homebridge?

In Toolkit:

image

And in Homebridge:

{
"type": "temperature",
"network": 254,
"application": 228,
"id": 5,
"channel": 1,
"name": "Phase1 Current",
"enabled": true
},
{
"type": "temperature",
"network": 254,
"application": 228,
"id": 5,
"channel": 2,
"name": "Phase2 Current",
"enabled": true
},
{
"type": "temperature",
"network": 254,
"application": 228,
"id": 5,
"channel": 3,
"name": "Phase3 Current",
"enabled": true
},
{
"type": "temperature",
"network": 254,
"application": 228,
"id": 5,
"channel": 4,
"name": "A/C Fan and Compressor",
"enabled": true
},

Then you can play with it while you wait for your sparky...

Cheers

Jason

@JasonY00
Copy link
Contributor

Have a look here for the installation and configuration of the node-red-contrib-homebridge-automation nodes in case I missed anything:

https://flows.nodered.org/node/node-red-contrib-homebridge-automation

Cheers

Jason

@glennoky
Copy link
Author

Hi Jason,

Thanks again for ALL the detailed help, very much appreciated.

My last error was remnants of the "Import", where I had to replace some double quotes with single quotes to get it to import and I wasn't methodical about reversing these. Once I had these fixed and restarted, some action! Yay! Values for a light are returned and zero values found for all three current sensors configured.

But zero current values is all I can achive. I've tried a couple of the clamps in slots 1 and 2 with them clamped around the power to my PC and using the "Status" in the Toolkit get nothing but zeros. Thinking I now definitely need my Sparky for this aspect.

The other thing I see not working is the accessory isn't being created in Homebridge (or I can't find it). Nothing in node-red-log other than the debug...

31 Jan 21:33:21 - [info] [debug:Total Current]
{ payload: { CurrentTemperature: 0 }, _msgid: 'd672d573d499f060' }

Hard for me to see anything in the Homebridge log other than the spaming the Airtouch4 plugin I have installed creates. Is there likely to be something in here?

Thanks again,
Glenn.

@JasonY00
Copy link
Contributor

JasonY00 commented Jan 31, 2024

Hi Glenn,

sounds good so far...remember in Toolkit that you have to set up the sensors to broadcast their values. I set them up to broadcast every minute:

image

I also set them up to broadcast whenever a change of 2% occurs:

image

Look carefully at the screens above and check your settings. Make sure you also have the "Measurement Device ID" set to the same value as the C-Bus Address of the unit as below:

image

This may fix your zero amps problem.

To see the new "total current" sensor in homekit, you then need to:

  1. choose the little "+" icon in homekit on your iOS device and,
  2. choose "Add Accessory". In the page that opens,
  3. choose "More Options" which is in an orange text.
  4. Then select "My Accessory Isn't Shown Here" and in the next page,
  5. select "Enter Code" which is also orange text.
  6. Put in your PIN from the Node Red Total Current Accessory you created, e.g. 111-11-112
  7. finish the import and check the "Default Room" in Homekit for your sensor.

Hopefully it will then import into Homekit and you will be good to go.

Cheers

Jason

@JasonY00
Copy link
Contributor

One more thing. See the little "Bug" Icon in Node-red. If you click that, it will give you a flowing log of everything as it happens.

image

@glennoky
Copy link
Author

glennoky commented Feb 1, 2024

Hi Jason,

My created accessory is now visible. The issue here was I'd used the HB Pin, so once I'd changed this to 1111-1111, I was able to add it.

While I did have a mismatch with "Measurement Device ID" and "Address", once they were the same, no change. While I have wound the broadcast interval down to 10 seconds, no change. But I am checking and expection values on the Status tab. Do you see values other than zero "Measured Values" here? And I've pressed "Update Status" a few times. :)

image

So, possibly all working, except the basic principle of the whole deal, measured values. Yay. :)

Thanks,
Glenn.

@JasonY00
Copy link
Contributor

JasonY00 commented Feb 1, 2024

Hi Glenn,

I'm gonna call this a win so far. It may be that the current of the device that you are testing it with is just not enough to register on the sensor even at the lowest 40A range. You can coil the power cord up and loop it through the sensor a few of times for measuring smaller currents. It increases the magnetic field that the current clamp measures and it may register a reading if this is the problem. The clamps are designed for this and in toolkit, it divides the current by the number of turns. That is what the "Turn Count" value is for each channel in the toolkit config screen.

These current sensors work on the "right hand rule" where a current carrying conductor sets up a circular magnetic field around the conductor directly proportional to the current flow. This is what's measured. Its how motors/generators work. Thanks to Michael Faraday! These things are basically mini transformers.

You should see the broadcasted values in Toolkit as below:

image

Are you also seeing it in the log?

image

Anyway, check the above if you want to, but I think you may be there...

Let me know how it all goes when you finally put them on the switchboard phases.

Congratulations and welcome to Node-Red. Now you can get any value you want from any homebridge accessory and do anything with it! You can even publish the data to a webpage with the nodes below!

image

Cheers

Jason

@JasonY00
Copy link
Contributor

JasonY00 commented Feb 1, 2024

This is a silly question, but are the sensors screwed into the correct terminals on the current measurement unit?

I have overlooked sillier things when trying to get something to work…

Cheers

Jason

@glennoky
Copy link
Author

glennoky commented Feb 2, 2024

Hi Jasson,

Stupid question time, where do I see the "Log" you show? I don't think it's something I know about.

I've now looped three times a portable floodlight, put in the count of three, and still no values but zeros in the Status tab.

Not such a silly question, as I still doubt I have the wiring correct, but I have tried several variations with no change. This is what I have though...

image

Thanks,
Glenn.

@JasonY00
Copy link
Contributor

JasonY00 commented Feb 2, 2024

Hi Glenn,

the log option is found in the left hand panel of your project tree in Toolkit:

image

The log lists plenty of decimal places, so the zero values would indicate something definitely not right...possibly something simple that we have missed.

You don't need to change the number of turns from 1 to 3 in the configuration. You are then effectively negating the multiple turns to increase the current measurement as you are then dividing the output again by 3 and going back to where you started.

The picture below is only for illustration of what you should do with your sensor and cable that you are trying to measure the current flow in. Remember that this is just a suggestion for this testing to ensure you are getting a reasonable amount of current for the sensor to give a decent reading. The sensor range is 0-40A and you are probably running a few hundred milliamps so you are way down the bottom of its range:

image

With the wiring of the sensors, it is measuring AC current, so polarity "may" not matter. However, the c-bus wiring diagrams show the black sensor wires in the A terminals and red to the B terminals like you have them. I can't remember if polarity matters...but lets follow the instructions.

In your photo, I don't see any pink c-bus cable behind the unit and obviously no Unit/C-Bus orange lights. Silly question time again: "is it patched into the cbus network?" or is it disconnected just to take the photo? Your earlier toolkit screenshots seem to indicate a network connected unit with healthy enough c-bus voltage etc.

Did you rescan the network in toolkit, make sure its also loaded to the database AND network and there are no device conflicts (i.e. duplicate addresses) and the serial number in toolkit matches the sticker on your Current Measurement Unit? Serial number is under the "Unit Identification" Tab in the device edit screen in Toolkit.

Your screen captures above show that you have opened the unit for programming from the database (top) window. Can you open the device from the network (bottom) window, check the config and make sure you save the programming to both the network and database.

image

I'm really trying to go back to basics here...so bear with me!

That's all I can think of at the moment. Can we check the above...?

Cheers

Jason

@glennoky
Copy link
Author

glennoky commented Feb 2, 2024

Hi Jason,

I guess I'd forgotten about the Log and have just gone staight to Units for my use of Toolkit since building and attending the training as a "Home Owner" back in 2006. So thanks! :) Here are my logged values, and they are a neat 0...

image

At this point I realise I've never connected all three clamps, but have always had the three Enabled, but with only one Enabled and the one clamp, no change. Have now enabled the all 4, just in case 1 was 4. All zero.

Three loops through the one clamp and turn count of 1, still zero.

Yes, I disconnected it from the network for the photo. Logistics of where the test cable resides and lighting. :)

I've rescanned, always save to both, and have edited from the bottom section, all good. Toolkit would tell me if I had a conflict? Only one device with 92 is found. Serial numbers match.

I'm good with going back to basics, I'm learning heaps! :)

I hope I've checked everything you've asked. Let me know if I've missed anything.

Thanks,
Glenn.

@JasonY00
Copy link
Contributor

JasonY00 commented Feb 3, 2024

Hi Glenn,

I must apologise for throwing you a red herring! In my keenness to get a current reading for you to test your node-red, I forgot that both the active and neutral wires (plus possible earth on a 3 pin plug) on any appliance cord will be within the clamp of the current sensor. Obviously, you will then then get 0.0000A for your current reading as the active and neutral are cancelling each other out! So, what that means is that you are all up and running and getting 0.0000A for each circuit as expected. When you finally connect the current sensors to the 3 Active phases coming out of your main switch, you will happily see your current flowing in toolkit as expected...

I have a second (spare Current Measurement Unit here and have rigged it up to show you. The setups below are of TPS 1mm twin and earth cable (in a lighting circuit) and 2 core 1mm appliance lead (multiple loops) through the sensors on channels 1 & 2 both giving 0.0000A in toolkit because the active and neutral are cancelling each other out.

TPS cable on Sensor 1
asd

2-core flex on sensor 2
qwe

and the result in toolkit:
image

compared to my current unit in the switchboard:
image

Please accept my apologies. I am embarrassed.....I think you are there!

Cheers

Jason

@glennoky
Copy link
Author

glennoky commented Feb 3, 2024

Hi Jason,

No apology necessary in the context of how much time and help you have given me! And this is excellent news! I do now remember you saying this earlier, so my miss as well.

I had a thought, but haven't gone through with it, as it would be dangerous and illegal for me to dig up an old appliance power cable, remove the sheath to expose the active wire, and attach a socket to the end, creating myself a test cable I could put in-line with my light. But if I were to do this, I'm sure I'd find that you are correct, and I have everything working, after I update the address from 1 to 92 in the Homebridge configuration of course. :)

Thanks heaps for the help, and the introduction to Node-RED. My job now is to learn what else I can use it for. I'm thinking I may be able to build a "Theartre On" group address and have Node-RED handle the detail, and be able to move completely away from TouchControl?

Thanks again,
Glenn.

@JasonY00
Copy link
Contributor

JasonY00 commented Feb 3, 2024

I'm still shaking my head in shame!

I suggest you have a look at the different devices in the node-red-contrib-homekit-bridged. I am currently looking at a garage door opener that takes Auxiliary Inputs from C-Bus for Door Open Reed, Door Close Reed and the obstruction sensor of my garage door opener. I also have a c-bus relay output that sends a 1 second pulse to the garage door opener to open/stop/close it.

The way that the homebridge-cbus plugin is written, it takes one c-bus Group Address and maps it to one homekit accessory. So a garage door opener which is a "composite" device with three c-bus inputs for open/close reeds & obstruction and one c-bus relay output for open/close/stop would require some recoding and logic changes in the plugin that seems just too hard... It can be realised as a "flow" in node-red with previous and current "states" to facilitate the open, closing, closed, opening, stopped states. Heater/Coolers & Thermostats work in a similar way, where you need a setpoint, temp sensor input and some form of damper/temperature control output. I am also playing with this, because in Node Red it is easier...

image

zxc

The garage door is a work in progress, but initial testing looks good so far...

image

Have fun and let me know how it all goes...

Cheers

Jason

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

2 participants