Allow device variables to inherit methods and properties of the physical device it is assigned


As a developer, I try to externalize devices as much as possible to minimize impact to code when something changes, such as a device replacing an old device (New phone, replaced outlet etc…). It also makes pistons more portable and also allows for easier duplication for use with similar device types.

It is much easier to change a variable to the new device than having to replace the device in dozens of places across multiple pistons.

However, when assigning a device to a variable, the variable doesn’t inherit the methods and properties of that device. The list is generic, and specific device type methods are missing. When adding triggers or events, the list of available properties and methods should be equivalent to the device assigned to the variable. This could be done by allowing users to cast the variable as a specific device type.

In order to achieve generic and portable code, the physical device has to be used for all triggers and actions. Once the piston is written, the physical device can be swapped out with the variable and things appear to still work. However, this can be tedious and is prone to mistakes. When editing the action, for example, the method disappears making it possible to accidentally remove the action, or change it to something that doesn’t work for that device type.


This has been discussed in the past. I think most people are aware, but I don’t think anything is going to be done about it.