Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
A control server for G-Homa wifi plugs written in node.
This library enables the use of the wifi plugs without the need to allow them to call home.
This library is intended to be used as part of a home automatization solution. For example, it can be used together with a framework like express.js to switch the plugs on or off by simple http calls.
$ npm install ghoma
This example shows the callback methods provided.
var ghoma = require('./ghoma.js');
// Uncomment this line to get a detailed log output
// ghoma.log=console.log;
// Register a listener for new plugs
ghoma.onNew = function(plug) {
console.log('Registerd ' + plug.remoteAddress+" "+plug.id);
// For this example switch the plug on in the moment it is registered.
plug.on();
}
// Called when the plug switches on or off
ghoma.onStatusChange = function(plug) {
console.log('New state of ' + plug.remoteAddress+' is '+plug.state+' triggered '+plug.triggered);
}
// Called when a enery measurement value was reported
ghoma.onMeasurement = function(plug, property) {
console.log('Measured '+property+' at '+plug.remoteAddress+'. Value is '+plug.energy[property].value);
}
// Called when the plug connection to the server was lost
ghoma.onClose = function(plug) {
console.log('Closed ' + plug.remoteAddress);
}
// Listen for heartbeats of the plugs
ghoma.onHeartbeat = function(plug) {
console.log('Heartbeat ' + plug.remoteAddress);
}
// Start a listening server on this port
ghoma.startServer(4196);
Usage example to configure a plug to a custom server (or restore defaults) from code
config.configure(gHomaPlugAddress, controlServer, controlPort, function (err) {
console.log(err ? 'Error: ' + err : 'Success');
} /*, console.log to enabled debug log*/);
//Restore default config of the plug
config.restore(gHomaPlugAddress, function (err) {
console.log(err ? 'Error: ' + err : 'Success');
}, console.log);
A more comprehensive example shows the node-ghoma library in combination with the express framework. See express_example.js in the git repository.
These notifications are triggered. See also example above.
Called when a new plug is registered with the control server.
Called if the plug was switched on or off.
Called if the plug has provided a new energy measurement. Only available for plugs with this capability. Property is the name of the measured energy velue.
Called if the connection to the plug was lost.
Called when a heartbeat event from the plug occurred.
Methods provided by the module.
Iterate through each registered plug object. The callback will receive the plug object.
Example:
ghoma.forEach(function(plug) {
console.log('Plug with id '+plug.id+' at '+plug.remoteAddress+' has state '+plug.state);
});
Helper method to get a plug by id. The id is the hex representation of the short mac of the plug. It can be used to unique identify the plug.
The plug object is used as callback argument for each notification and as a result of method calls.
{
id: "53ae11", // Unique ID of the plug. These are the last 3 bytes from the MAC address.
firmware : "2.18.6" // Plug firmware version
state: "on", // Current state. May be 'on','off' or 'unknown'
statechanged: "2017-01-22T21:00:19.733Z", // Time of the last state change
triggered: "local", // local: Triggered by switch on the plug. remote: Triggered by control server
prevstate: "off", // The previous state. May be 'unkown', if the plug has no state send until now
initalized: "2017-01-22T20:59:23.565Z", // Time the plug has registered with the control server
remoteAddress: "::ffff:192.168.1.136", // The address of the plug
remotePort: 14283, // The remote port
heartbeat: "2017-01-22T21:00:20.893Z", // Time of the last heartbeat call from the plug
reregistered : 2, // Number of re registrations of the plug. May be a indicator for the connection stability
on : // Function to switch the plug on
off : // Function to switch the plug off
energy : {} // Provided when using plugs with energy measurement funtionality (see below)
}
For plugs that provide energy measurement functionality (EMW302WF-CTL) there is also a energy object available, like :
{
energy: {
voltage: {
value: 220.1 // Current value
prevvalue: 220.5 // Previous reported value
count: 3 // Number of reportings
update : "2017-01-22T21:02:21.591Z", // Time of the last report for this value
}
...
}
}
These measurement properties are provided.
Name | Description |
---|---|
voltage | Net voltage |
current | Current |
frequency | Net frequency |
cosphi | Power factor |
energy | Enery usage in kWh added up |
power | Power value |
maxpower | Maximum power |
With firmware version <=1.0.06 you can use the embedded web server to adjust the control server address. See the fhem wiki page for instructions. With newer firmware version, this easy way to configure the plug is disabled.
One way to run your own control server is to setup your own DNS and DHCP service. Then the DNS entry for 'plug.g-homa.com' must point to your own server and you are forced to use '4196' as listening port.
Another way that may work for you is to use this node script to change the control server. See config.js.
Note: If you re-configure the plug to use the new control server, the android or ios app won't work any more.
Version 1.1.0
Version 1.0.7 (thx to msteiger)
Version 1.0.6 (thx to jaumard)
Version 1.0.5
Version 1.0.4
Version 1.0.3
Version 1.0.2
Version 1.0.1
Version 1.0.0
The network protocol was deciphered by others - full credits go to them. See the FHEM Wiki Page (german) and Full disclosure for gHoma on seclists (german).
The hardware producer site can be found here (also in german).
FAQs
A control server for g-homa wifi plugs.
We found that ghoma demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.