[{"server":null,"owner":null,"id":"5cee4c6d-85d2-4ce5-8ee8-509d7fc907ee","params":{"typedef":{"value":"","datetime":1523889548,"status":null,"version":0},"result":{"value":null,"datetime":1523889548,"status":null,"version":0},"hash":{"value":"k8RnYybhq/aE9Q2CiuiU1w==","datetime":1523964503,"status":null,"version":0},"enabled":{"value":false,"datetime":1523964583,"status":null,"version":0},"error_text":{"value":null,"datetime":1523964597,"status":null,"version":0},"type":{"value":"EgsObjectUpdated","datetime":1523963933,"status":null,"version":0},"settings":{"value":"{\"item_type\":\"Sensor\",\"item_pin\":\"zoneInputPin\",\"proxy_type\":\"Zone\",\"proxy_pin\":\"zoneOutputPin\"}","datetime":1523964596,"status":null,"version":0},"state":{"value":"ok.normal","datetime":1523964597,"status":null,"version":0},"script":{"value":"# имя: 'Proxy item 2'\r\n# описание: прокси - заместитель связанного устройства\r\n# тип триггера: 'EgsObjectUpdated'\r\n# создан: 2018.02.28 17.37.48, Сельченков Н.Ю.\r\n# изменен: '2018.04.17 15.28.22', Сельченков Н.Ю.\r\n# подробности: https://redmine.integra-s.com:11000/projects/eilyacuario/wiki/Proxy_item_2\r\n\r\nuse Newtonsoft.Json.JsonConvert from Newtonsoft.Json\r\n\r\nuse typedef\r\n`\r\n    <root>\r\n        <param name=\"item_type\" type=\"text\" />\r\n        <param name=\"item_pin\" type=\"text\" />\r\n        <param name=\"proxy_type\" type=\"text\" />\r\n        <param name=\"proxy_pin\" type=\"text\" />\r\n    </root>\r\n` as Settings\r\n\r\nconst settings = Settings(trigger.settings)\r\n\r\nuse (\"acuario2.types.\" + settings.item_type) as ItemType from acuario2.types\r\nuse (\"acuario2.types.\" + settings.proxy_type) as ProxyType from acuario2.types\r\n\r\nif @object is Item then\r\n    let item = @object as ItemType \r\n    if (item isnt nil) and (\"state\" in changes) then\r\n        let source = item[\"state\"]\r\n        from item.(settings.item_pin).GetOppositeItems() where it is ProxyType do \r\n            let target = it[\"state\"]\r\n            if source.Text in target.EnumNames then target.Set(source.Text, source.Status, source.DateTime)\r\n            else switch item.State\r\n                when \"ok\" then target.Set(\"ok_normal\", source.Status, source.DateTime)\r\n                when \"error\" then target.Set(\"error_defective\", source.Status, source.DateTime)\r\n                when \"alarm\" then target.Set(\"alarm_alarm\", source.Status, source.DateTime)\r\n                when \"none\" then target.Set(\"none_unknown\", source.Status, source.DateTime)\r\n                else target.Set(\"DEFAULT\", Status.invalid, source.DateTime)\r\n        now\r\n    end\r\n\r\n    let proxy = @object as ProxyType\r\n    if (proxy isnt nil) and (\"command\" in changes) then\r\n        let source = proxy[\"command\"].Old ?? proxy[\"command\"]\r\n        from proxy.(settings.proxy_pin).GetOppositeItems() where it is ItemType do \r\n            let target = it[\"command\"]\r\n            if source.Text in target.EnumNames then target.Set(source.Text, source.Status, source.DateTime) \r\n            else target.Set(\"DEFAULT\", Status.invalid, source.DateTime)\r\n        now\r\n    end\r\nend\r\n","datetime":1523964597,"status":null,"version":0},"name":{"value":"Proxy item 2","datetime":1523889548,"status":null,"version":0}},"entity":"item","operation":"create"}]