uses PG-Communication (programming device communication) to connect the PLC
optional also OP-Communication (HMI or panel communication) can be used for to connect the PLC
NOTE: You may need to increase the connection resources for PG-Communication or OP-Communication within Siemens Simatic Manager or Siemens TIA Portal. The default value is 1 and thus lead to connection problems using programming tool or panel and this plugin at the same time.
Tested with S7-300, S7-1200 and S7-300 compatible PLCs from Yaskawa
Implementation is based on documentation of the Homebridge API
Supports polling of PLC from homebridge-plc plugin by per accessory defined interval
Supports push from PLC to homebridge-plc plugin by http PUT/GET
Supports control of PLC accessories by http PUT/GET
Install this plugin using: sudo npm install -g homebridge-plc
Edit config.json to add the plc platform and its accessories.
Run Homebridge
Install via Homebridge UI (recommended)
Search for plc on the plugin screen of config-ui-x .
Find homebridge-plc
Click install.
Edit configuration
Homebridge configuration
Platform
The plugin is configured as single platform by defining a PLC platform.
Parameters:
ip: the IPv4 address of the PLC
rack: the rack number of the PLC typically 0
slot: the slot number of the PLC for S7 300/400 typically 2, for 1200/1500 typically 1.
communicationOP: (optional) when set to true OP-Communication is used instead of PG-Communication
enablePolling: (optional) when set to true a background task is executed every second enable polling for the accessories
defaultPollInterval(optional) default polling interval for all accessories in seconds. Default value is 10 seconds
distributePolling(optional) when set to true the polling of the accessories does not start at the same time. In order to distribute the PLC load for the queries
enablePush: (optional) when set to true a the configured port is opened to push updates of values form plc to the plugin
enableControl: (optional) when set to true a the configured port is opened to control accessories by http request
port: (optional) port for http server to handle incoming http requests for push and control functionality. Default port is 8888
forward: (optional) there is a limit of maximum 149 supported accessories by homebridge. To overcome this is limited you can create a second instance of homebridge running homebridge-plc and forward all push and control with no matching db to the other instance. Set the destination address of the second instance e.g. http:\\127.0.0.1:8889.
mirror(optional) There are environments where it could make sense to share the same accessories on two homebridge instances. To allow pairing with another Home with Apple Home App or Home Assistant. This option mirrors all values read from PLC by this instance to a second instance. It also forwards all push requests to the second instance. The option enablePush has to be enabled on the second instance. on the destination instance. Set the destination address of the second instance e.g. http:\\192.168.1.11:8888. (expirimental feature)
Accessories
In the platform, you can declare different types of accessories
The notation (push support) identifies that parameter supports direct updates from the PLC
The notation (control support) identifies parameters that can be controlled by http request
enablePolling: (optional) when set to true the current state will be polled. It is mandatory as well to enable polling mode on platform level.
pollInterval: (optional) poll interval in seconds. Default value see platform definition.
get_On: (push support) offset and bit get the current status S7 type Bool e.g. 55.0 for DB4DBX55.0
Single Bit for on/off:
set_On: (control support) offset and bit set to 1/0 when switching on/off S7 type Bool PLC e.g. 55.0 for DB4DBX55.0 could be same as get_On
Separate Bits for on/off:
set_On: (control support) offset and bit set to 1 when switching on S7 type BoolPLC has to set to 0 e.g. 55.1 for DB4DBX55.1
set_Off: offset and bit set to 1 when switching off S7 type BoolPLC has to set to 0 e.g. 55.2 for DB4DBX55.2
get_Brightness: (optional)(push support) get brightness value S7 type Byte e.g. 56 for DB4DBB56
set_Brightness: (optional but required when get_Brightness is defined)(control support) set brightness value S7 type Byte e.g. 57 for DB4DBB57
brightness range definitions (optional)
minValue default value: 20
maxValue default value: 100
minStep default value: 1
Outlet as PLC_Outlet
outlet possible to show also as ventilator or light
name: unique name of the accessory
manufacturer: (optional) description
db: s7 data base number e.g. 4 for DB4
enablePolling: (optional) when set to true the current state will be polled. It is mandatory as well to enable polling mode on platform level.
pollInterval: (optional) poll interval in seconds. Default value see platform definition.
get_On: (push support) offset and bit get the current status S7 type Bool e.g. 55.0 for DB4DBX55.0
Single Bit for on/off:
set_On: (control support) offset and bit set to 1/0 when switching on/off S7 type Bool PLC e.g. 55.0 for DB4DBX55.0 could be same as get_On
Separate Bits for on/off:
set_On: (control support) offset and bit set to 1 when switching on S7 type BoolPLC has to set to 0 e.g. 55.1 for DB4DBX55.1
set_Off: offset and bit set to 1 when switching off S7 type BoolPLC has to set to 0 e.g. 55.2 for DB4DBX55.2
Switch as PLC_Switch
switch possible to show also as ventilator or light
name: unique name of the accessory
manufacturer: (optional) description
db: s7 data base number e.g. 4 for DB4
enablePolling: (optional) when set to true the current state will be polled. It is mandatory as well to enable polling mode on platform level.
pollInterval: (optional) poll interval in seconds. Default value see platform definition.
get_On: (push support) offset and bit get the current status S7 type Bool e.g. 55.0 for DB4DBX55.0
Single Bit for on/off:
set_On: (control support) offset and bit set to 1/0 when switching on/off S7 type Bool PLC e.g. 55.0 for DB4DBX55.0 could be same as get_On
Separate Bits for on/off:
set_On: (control support) offset and bit set to 1 when switching on S7 type BoolPLC has to set to 0 e.g. 55.1 for DB4DBX55.1
set_Off: offset and bit set to 1 when switching off S7 type BoolPLC has to set to 0 e.g. 55.2 for DB4DBX55.2
Temperature Sensor as PLC_TemperatureSensor
normal temperature sensor
name: unique name of the accessory
manufacturer: (optional) description
db: s7 data base number e.g. 4 for DB4
enablePolling: (optional) when set to true the current state will be polled. It is mandatory as well to enable polling mode on platform level.
pollInterval: (optional) poll interval in seconds. Default value see platform definition.
get_CurrentTemperature: (push support) offset to get current temperature S7 type Real e.g. 55 for DB4DBD55
temperature range (optional)
minValue default value: -50
maxValue default value: 110
minStep default value: 0.5
get_StatusTampered: (optional)(push support) offset and bit to tamper detection. (Home app shows this only within the options) S7 type Bool e.g. 55.2 for DB4DBX55.2
false: ok
true: tampered
get_StatusLowBattery: (optional)(push support) offset and bit to battery low detection. (Home app does not inform with push notification) S7 type Bool e.g. 55.3 for DB4DBX55.3
false: ok
true: battery low
Humidity Sensor as PLC_HumiditySensor
normal humidity sensor
name: unique name of the accessory
manufacturer: (optional) description
db: s7 data base number e.g. 4 for DB4
enablePolling: (optional) when set to true the current state will be polled. It is mandatory as well to enable polling mode on platform level.
pollInterval: (optional) poll interval in seconds. Default value see platform definition.
get_CurrentRelativeHumidity: (push support) offset to get current humidity S7 type Real e.g. 55 for DB4DBD55
humidity range (optional)
minValue default value: 0
maxValue default value: 100
minStep default value: 1
get_StatusTampered: (optional)(push support) offset and bit to tamper detection. (Home app shows this only within the options) S7 type Bool e.g. 55.2 for DB4DBX55.2
false: ok
true: tampered
get_StatusLowBattery: (optional)(push support) offset and bit to battery low detection. (Home app does not inform with push notification) S7 type Bool e.g. 55.3 for DB4DBX55.3
false: ok
true: battery low
Thermostat as PLC_Thermostat
temperature / humidity sensor with temperature / humidity regulation
name: unique name of the accessory
manufacturer: (optional) description
db: s7 data base number e.g. 4 for DB4
enablePolling: (optional) when set to true the current state will be polled. It is mandatory as well to enable polling mode on platform level.
pollInterval: (optional) poll interval in seconds. Default value see platform definition.
get_CurrentTemperature: (push support) offset to get current temperature S7 type Real e.g. 0 for DB4DBD0
Target Temperature
get_TargetTemperature: (push support) offset to get target temperature S7 type Real e.g. 4 for DB4DBD4
set_TargetTemperature: (control support) offset to set current temperature S7 type Real e.g. 4 for DB4DBD4 (can have same value as get_TargetTemperature)
target temperature range definitions (optional)
minValue default value: 15
maxValue default value: 27
minStep default value: 0.5 Note: lower values seems not be supported by Homekit
get_CurrentRelativeHumidity: (optional)(push support) offset to get current humidity S7 type Real e.g. 0 for DB4DBD0
Target Humidity
get_TargetRelativeHumidity: (optional)(push support) offset to get target temperature S7 type Real e.g. 4 for DB4DBD4
set_TargetRelativeHumidity: (optional)(control support) offset to set current temperature S7 type Real e.g. 4 for DB4DBD4 (can have same value as get_TargetTemperature)
target relative humidity range definitions (optional)
minHumidityValue default value: 0
maxHumidityValue default value: 100
minHumidityStep default value: 1
Current State:
get_CurrentHeatingCoolingState: (optional)(push support) offset to get current heating/cooling state S7 type Byte e.g. 8 for DB4DBB8. When not defined fixed 1: heating is used.
0: inactive (shown as green in home app)
1: heating (shown as orange in home app)
2: cooling (shown as blue in home app)
mapGetCurrent: (optional) define mapping array for get_CurrentHeatingCoolingState. The PLC value is used as index into the table. e.g. [0, 2] which maps the PLC value 0->0 1->2 when the PLC supports only two states with 0:inactive and 1:cooling.
Target State:
get_TargetHeatingCoolingState(optional)(push support) offset to get target heating/cooling state. S7 type Byte e.g. 9 for DB4DBB9. When not defined fixed 3: automatic is used.
0: off
1: heat
2: cool
3: automatic
mapGetTarget: (optional) define mapping array for get_TargetHeatingCoolingState. The PLC value is used as index into the table. e.g. [0, 3] which maps the PLC value 0->0 1->3 when the PLC supports only two states with 0:off and 1:automatic.
set_TargetHeatingCoolingState(optional)(control support) offset to set target heating/cooling state. Can be identical with get_TargetHeatingCoolingState. Has to be defined when get_TargetHeatingCoolingState is defined. When not defined writes changes are ignored. S7 type Byte e.g. 9 for DB4DBB9.
0: off
1: heat
2: cool
3: automatic
mapSetTarget: (optional) define mapping array for set_TargetHeatingCoolingState. The home app value is used as index into the table. e.g. [0, 1, 0, 3] which maps the PLC value 0->0 1->1 2->0, 3->3 when the PLC supports only two states with 0:off and 1:heat and 3:automatic. The state cool is mapped to off.
get_StatusTampered: (optional)(push support) offset and bit to tamper detection. (Home app shows this only within the options) S7 type Bool e.g. 55.2 for DB4DBX55.2
false: ok
true: tampered
get_StatusLowBattery: (optional)(push support) offset and bit to battery low detection. (Home app does not inform with push notification) S7 type Bool e.g. 55.3 for DB4DBX55.3
false: ok
true: battery low
Thermostat as PLC_HumidifierDehumidifier
Humidifier and/or Dehumidifier
name: unique name of the accessory
manufacturer: (optional) description
db: s7 data base number e.g. 4 for DB4
enablePolling: (optional) when set to true the current state will be polled. It is mandatory as well to enable polling mode on platform level.
pollInterval: (optional) poll interval in seconds. Default value see platform definition.
get_CurrentRelativeHumidity: (push support) offset to get current humidity S7 type Real e.g. 55 for DB4DBD55
get_Active: (push support) offset and bit get the current status S7 type Bool e.g. 55.0 for DB4DBX55.0
Single Bit for on/off:
set_Active: (control support) offset and bit set to 1/0 when switching on/off S7 type Bool PLC e.g. 55.0 for DB4DBX55.0 could be same as get_Active
Separate Bits for on/off:
set_Active: (control support) offset and bit set to 1 when switching on S7 type BoolPLC has to set to 0 e.g. 55.1 for DB4DBX55.1
set_Deactivate: offset and bit set to 1 when switching off S7 type BoolPLC has to set to 0 e.g. 55.2 for DB4DBX55.2
Current State
get_CurrentHumidifierDehumidifierState: (optional)(push support) offset to get current state. Default value 1:idle. S7 type Byte e.g. 55 for DB4DBD55
0: inactive
1: idle
2: humidifying
3: dehumidifying
mapGetCurrent: (optional) define mapping array for get_CurrentHumidifierDehumidifierState. The PLC value is used as index into the table. e.g. [1, 3] which maps the PLC value 0->1 1->3 when the PLC supports only two states with 0:idle and 1:dehumidifying.
Target State
default_TargetHumidifierDehumidifierState: (optional) defines alternative value thats returned then get_TargetHumidifierDehumidifierState is not defined. Default value 0:auto
0: auto (humidifier or dehumidifier)
1: humidifier
2: dehumidifier
get_TargetHumidifierDehumidifierState: (optional)(push support) offset to get current target state S7 type Byte e.g. 55 for DB4DBD55
0: auto (humidifier or dehumidifier)
1: humidifier
2: dehumidifier
set_TargetHumidifierDehumidifierState: (optional) **(control support)**offset to set current target state. Needs to be defined when get_TargetHumidifierDehumidifierState is set S7 type Byte e.g. 55 for DB4DBD55
0: auto (humidifier or dehumidifier)
1: humidifier
2: dehumidifier
mapGetTarget: (optional) define mapping array for get_TargetHumidifierDehumidifierState. The PLC value is used as index into the table. e.g. [0] which maps the PLC value 0->2 1->3 when the PLC supports only one states with `0:dehumidifier.
mapSetTarget: (optional) define mapping array for set_TargetHumidifierDehumidifierState. The home app value is used as index into the table. e.g. `[2, 2, 2
Rotation Speed
Byte
get_RotationSpeedByte: (optional)(push support) offset to get rotation speed state S7 type Byte e.g. 8 for DB4DBB8.
set_RotationSpeedByte(optional but required when set_RotationSpeedByte is defined)(push support) offset to get set speed state. S7 type Byte e.g. 9 for DB4DBB9.
Real
get_RotationSpeed: (optional)(push support) offset to get rotation speed state S7 type Real e.g. 8 for DB4DBB8.
set_RotationSpeed(optional but required when get_RotationSpeed is defined)(push support) offset to get set speed state. S7 type Real e.g. 9 for DB4DBB9.
Swing Mode
get_SwingMode: (optional)(push support) offset to get rotation speed state S7 type Bool e.g. 8 for DB4DBB8.
set_SwingMode(optional)(push support) offset to get set speed state. S7 type Bool e.g. 9 for DB4DBB9.
Water Level
get_WaterLevel: (optional)(push support) offset to get rotation speed state S7 type Real e.g. 8 for DB4DBB8.
get_StatusTampered: (optional)(push support) offset and bit to tamper detection. (Home app shows this only within the options) S7 type Bool e.g. 55.2 for DB4DBX55.2
false: ok
true: tampered
get_StatusLowBattery: (optional)(push support) offset and bit to battery low detection. (Home app does not inform with push notification) S7 type Bool e.g. 55.3 for DB4DBX55.3
false: ok
true: battery low
Shutters as PLC_WindowCovering, windows as PLC_Window and doors as PLC_Door
motor driven blinds, windows and doors. Supports also manual driven blinds, windows and doors to show just the current position in percent. Note: If your sensor shows only open/close may also have a look at PLC_ContactSensor.
name: unique name of the accessory
manufacturer: (optional) description
db: s7 data base number e.g. 4 for DB4
adaptivePolling: (optional) when set to true the current position will be polled until target position is reached. Polling starts with set target position from home app. This allows to show the shutter as opening... or closing... in the home app during movement.
adaptivePollingInterval(optional) poll interval in seconds during high frequency polling. Default value is 1 second.
forceCurrentPosition(optional) when set to true the position set by set_TargetPosition is directly used as current position. By this it seems in tha home app as the target position was directly reached. This is recommended when not using adaptivePolling or pushing the value from the plc.
enablePolling: (optional) when set to true the current state will be polled. It is mandatory as well to enable polling mode on platform level.
pollInterval: (optional) poll interval in seconds. Default value see platform definition.
Current position:
get_CurrentPosition: (push support) offset to get current position 0:closed 100:open S7 type Byte e.g. 0 for DB4DBB0
0: closed
in between: partly open
100: open
invert: (optional) set to true to inverts the values of current and target position from 0:closed 100:open to 100:closed 0:open
mapGet: (optional) define mapping array for get position. The PLC value is used as index into the table. e.g. [0, 25, 100] which maps the PLC value 0->0 1->25 2->100 this this is useful e.g. for window open state.
Target position:
if one of the (optional) target position settings need specified all are needed. If not specified it os not movable ans sticks to current position.
get_TargetPosition: (optional)(push support) offset to get target position S7 type Byte e.g. 1 for DB4DBB1 (can have same value as set_TargetPosition)
0: closed
in between: partly open
100: open
set_TargetPosition: (optional)(control support) offset to set current position 0:closed 100:open S7 type Byte e.g. 2 for DB4DBB2 (can have same value as get_TargetPosition)
0: closed
in between: partly open
100: open
invert: (optional) set to true to inverts the values of current and target position from 0:closed 100:open to 100:closed 0:open
get_PositionState: (optional)(push support) offset to current movement state if not defined fixed 2is returned S7 type Byte e.g. 3 for DB4DBB3
0: down
1: up
2: stop
set_HoldPosition: (optional)(control support) offset and bit set to 1 to stop movement. (Seems not to be used) when not defined writes will be ignoredS7 type BoolPLC has to set to 0 e.g. 55.1 for DB4DBX55.1
Occupancy Sensor as PLC_OccupancySensor
presence detection sensor
name: unique name of the accessory
manufacturer: (optional) description
db: s7 data base number e.g. 4 for DB4
invert: (optional) set to true inverts the bit to false:presence and true:no-presence.
enablePolling: (optional) when set to true the current state will be polled. It is mandatory as well to enable polling mode on platform level.
pollInterval: (optional) poll interval in seconds. Default value see platform definition.
get_OccupancyDetected: (push support) offset and bit get the current status S7 type Bool e.g. 55.0 for DB4DBX55.0
false: no occupancy
true: occupancy detected
get_StatusTampered: (optional)(push support) offset and bit to tamper detection. (Home app shows this only within the options) S7 type Bool e.g. 55.2 for DB4DBX55.2
false: ok
true: tampered
get_StatusLowBattery: (optional)(push support) offset and bit to battery low detection. (Home app does not inform with push notification) S7 type Bool e.g. 55.3 for DB4DBX55.3
false: ok
true: battery low
Motion Sensor as PLC_MotionSensor
movement detection sensor
name: unique name of the accessory
manufacturer: (optional) description
db: s7 data base number e.g. 4 for DB4
invert: (optional) set to true inverts the bit to false:motion and true:no-motion.
enablePolling: (optional) when set to true the current state will be polled. It is mandatory as well to enable polling mode on platform level.
pollInterval: (optional) poll interval in seconds. Default value see platform definition.
get_MotionDetected: (push support) offset and bit get the current status S7 type Bool e.g. 55.0 for DB4DBX55.0
false: no motion
true: motion detected
get_StatusTampered: (optional)(push support) offset and bit to tamper detection. (Home app shows this only within the options) S7 type Bool e.g. 55.2 for DB4DBX55.2
false: ok
true: tampered
get_StatusLowBattery: (optional)(push support) offset and bit to battery low detection. (Home app does not inform with push notification) S7 type Bool e.g. 55.3 for DB4DBX55.3
false: ok
true: battery low
Contact Sensor as PLC_ContactSensor
generic contact sensor. The home app allows to display as window, door, blind/shutter, garage door or contact sensor.
name: unique name of the accessory
manufacturer: (optional) description
db: s7 data base number e.g. 4 for DB4
invert: (optional) set to true inverts the bit to false:closed and true:open.
enablePolling: (optional) when set to true the current state will be polled. It is mandatory as well to enable polling mode on platform level.
pollInterval: (optional) poll interval in seconds. Default value see platform definition.
get_ContactSensorState: (push support) offset and bit get the current status S7 type Bool e.g. 55.0 for DB4DBX55.0
false: closed
true: open
get_StatusTampered: (optional)(push support) offset and bit to tamper detection. (Home app shows this only within the options) S7 type Bool e.g. 55.2 for DB4DBX55.2
false: ok
true: tampered
get_StatusLowBattery: (optional)(push support) offset and bit to battery low detection. (Home app does not inform with push notification) S7 type Bool e.g. 55.3 for DB4DBX55.3
false: ok
true: battery low
Contact Sensor as PLC_LeakSensor
leak sensor
name: unique name of the accessory
manufacturer: (optional) description
db: s7 data base number e.g. 4 for DB4
invert: (optional) set to true inverts the bit to false:closed and true:open.
enablePolling: (optional) when set to true the current state will be polled. It is mandatory as well to enable polling mode on platform level.
pollInterval: (optional) poll interval in seconds. Default value see platform definition.
get_LeakDetected: (push support) offset and bit get the current status S7 type Bool e.g. 55.0 for DB4DBX55.0
false: leak not detected
true: leak detected
get_StatusTampered: (optional)(push support) offset and bit to tamper detection. (Home app shows this only within the options) S7 type Bool e.g. 55.2 for DB4DBX55.2
false: ok
true: tampered
get_StatusLowBattery: (optional)(push support) offset and bit to battery low detection. (Home app does not inform with push notification) S7 type Bool e.g. 55.3 for DB4DBX55.3
false: ok
true: battery low
Faucet as PLC_Faucet
watering for the garden
name: unique name of the accessory
manufacturer: (optional) description
db: s7 data base number e.g. 4 for DB4
enablePolling: (optional) when set to true the current state will be polled. It is mandatory as well to enable polling mode on platform level.
pollInterval: (optional) poll interval in seconds. Default value see platform definition.
get_Active: (push support) offset and bit get the current status S7 type Bool e.g. 55.0 for DB4DBX55.0
Single Bit for on/off:
set_Active: (control support) offset and bit set to 1/0 when switching on/off S7 type Bool PLC e.g. 55.0 for DB4DBX55.0 could be same as get_Active
Separate Bits for on/off:
set_Active: (control support) offset and bit set to 1 when switching on S7 type BoolPLC has to set to 0 e.g. 55.1 for DB4DBX55.1
set_Deactivate: offset and bit set to 1 when switching off S7 type BoolPLC has to set to 0 e.g. 55.2 for DB4DBX55.2
Valve as PLC_Valve
valve configurable as generic valve, irrigation, shower head or water faucet
name: unique name of the accessory
manufacturer: (optional) description
db: s7 data base number e.g. 4 for DB4
enablePolling: (optional) when set to true the current state will be polled. It is mandatory as well to enable polling mode on platform level.
pollInterval: (optional) poll interval in seconds. Default value see platform definition.
ValveType configures the valve type that is returned
0: generic valve
1: irrigation
2: shower head
3: water faucet
get_Active: (push support) offset and bit get the current status S7 type Bool e.g. 55.0 for DB4DBX55.0
Single Bit for on/off:
set_Active: (control support) offset and bit set to 1/0 when switching on/off S7 type Bool PLC e.g. 55.0 for DB4DBX55.0 could be same as get_Active
Separate Bits for on/off:
set_Active: (control support) offset and bit set to 1 when switching on S7 type BoolPLC has to set to 0 e.g. 5
请发表评论